- 1
- 2
http://my.sec.ru/author.cfm
http://daily.sec.ru/search.cfm?s=%22+%2F%3E
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+126
http://my.sec.ru/author.cfm
http://daily.sec.ru/search.cfm?s=%22+%2F%3E
И это называется портал по безопасности...
+126
if ((e.Row.Cells[0].Text.Trim() != "") && (e.Row.Cells[0].Text.Trim().ToUpper() != "NULL".Trim().ToUpper()))
Indian style
Проверка ячейки таблицы на null
+126
public static bool IsLong(string tmpStr)
{
bool blRetVal = true;
for (int i = 0; i < tmpStr.Length; i++)
{
if (tmpStr[i] != '0' && tmpStr[i] != '1' && tmpStr[i] != '2' &&
tmpStr[i] != '3' && tmpStr[i] != '4' && tmpStr[i] != '5' &&
tmpStr[i] != '6' && tmpStr[i] != '7' && tmpStr[i] != '8' &&
tmpStr[i] != '9')
blRetVal = false;
}
return blRetVal;
}
static public string ConvertDateTimeForSQL(DateTime tmpDateTime)
{
return (
tmpDateTime.Year.ToString() + "-" +
(tmpDateTime.Month < 10 ? "0" : "") + tmpDateTime.Month.ToString() + "-" +
(tmpDateTime.Day < 10 ? "0" : "") + tmpDateTime.Day.ToString() + " " +
(tmpDateTime.Hour < 10 ? "0" : "") + tmpDateTime.Hour.ToString() + ":" +
(tmpDateTime.Minute < 10 ? "0" : "") + tmpDateTime.Minute.ToString() + ":" +
(tmpDateTime.Second < 10 ? "0" : "") + tmpDateTime.Second.ToString());
}
static public string ConvertDateTimeShortForSQL(DateTime tmpDateTime)
{
return (tmpDateTime.Year.ToString() + "-" +
(tmpDateTime.Month < 10 ? "0" : "") + tmpDateTime.Month.ToString() + "-" +
(tmpDateTime.Day < 10 ? "0" : "") + tmpDateTime.Day.ToString());
}
-----------------------------------
P.S. Версия .NET 3.5
+126
//javax.swing.JTree
public void setBounds(Rectangle r) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setBounds(r);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.setBounds(r);
}
}
}
public void setSize (Dimension d) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setSize(d);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.setSize(d);
}
}
}
public void requestFocus() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).requestFocus();
} else {
Component c = getCurrentComponent();
if (c != null) {
c.requestFocus();
}
}
}
public void addFocusListener(FocusListener l) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).addFocusListener(l);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.addFocusListener(l);
}
}
}
public boolean isFocusTraversable() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).isFocusTraversable();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.isFocusTraversable();
} else {
return false;
}
}
}
+126
if ((properties.ListItem["LocationTaxID"].ToString() != string.Empty) || (properties.ListItem["LocationTaxID"] != null))
{
}
Норвеги писаки-проверяки.
+126
[img]http://www.cosplayisland.co.uk/files/costumes/3606/48808/9131%20-%20animated_gif%20haters_gonna_hate%20my_little_pony_friendship_is_magic%20rainbow_dash%20tagme.gif[/img]
+126
public static bool GetSafeBool(object val, bool defaultVal)
{
//TODO: check functionality
bool result = defaultVal;
try
{
if (val != null)
{
string str = val.ToString().Trim();
// compare ignore case, for performance
result = (0 == string.Compare(str, true.ToString(), true) || str == "1" || str == "-1");
}
}
catch { }
return result;
}
Продолжая тему расовых индусов...
+126
good luck, suckers!
+126
//calculate elapsed time
TimeSpan elapsed = DateTime.Now - startTime;
//if a second has elapsed
if (lastSecond != elapsed.Seconds)
{
//store last second
lastSecond = elapsed.Seconds;
//get hours
string hours;
if (elapsed.Hours < 10)
hours = "0" + elapsed.Hours.ToString();
else
hours = elapsed.Hours.ToString();
//get minutes
string minutes;
if (elapsed.Minutes < 10)
minutes = "0" + elapsed.Minutes.ToString();
else
minutes = elapsed.Minutes.ToString();
//get seconds
string seconds;
if (elapsed.Seconds < 10)
seconds = "0" + elapsed.Seconds.ToString();
else
seconds = elapsed.Seconds.ToString();
//update label
this.lblElapsedTime.Text = "Elapsed time: " + hours + ":" + minutes + ":" + seconds;
}
Явно автор сего кода был не знаком со string.format.
+126
public bool NewOrder {
get {
if( !string.IsNullOrEmpty( Request.QueryString[ "NewOrder" ] ) ) {
ViewState[ "NewOrder" ] = Request.QueryString[ "NewOrder" ] == "true" ? true : false;
} else {
if( ViewState[ "NewOrder" ] != null )
return ( bool ) ViewState[ "NewOrder" ];
else
ViewState[ "NewOrder" ] = true;
}
return ( bool ) ViewState[ "NewOrder" ];
}
set { ViewState[ "NewOrder" ] = value; }
}