- 1
- 2
- 3
- 4
- 5
if (!isset($caseMenu['child'])) {
$catsArr['list'][$caseMenu['parent']]['status'] = "active";
}else{
$catsArr['list'][$caseMenu['parent']]['children']['list'][0]['status'] = "active";
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
if (!isset($caseMenu['child'])) {
$catsArr['list'][$caseMenu['parent']]['status'] = "active";
}else{
$catsArr['list'][$caseMenu['parent']]['children']['list'][0]['status'] = "active";
}
помоему это охуенно
+146
static void WriteToFile()
{
StreamWriter SW;
SW=File.CreateText("c:\\MyTextFile.txt");
SW.WriteLine("God is greatest of them all");
SW.WriteLine("This is second line");
SW.Close();
Console.WriteLine("File Created SucacessFully");
}
SucacessFully, что здесь непонятного!)
А строки 3 и 4 стоило написать в одну строчку сразу.
Источник: http://www.csharphelp.com/2005/12/simple-text-file-operations-in-c/
+160
if($('#month1').attr('value') == 2 ||
$('#month2').attr('value') == 2){
if($('#day1').attr('value') > 29 ||
$('#day2').attr('value') > 29){
alert('Неправильная дата');
return 0;
}
}
Проверка двух дат на 30 февраля.
+131
DateTime dt = DateTime.Parse(DateTime.Now.ToString("dd.MM.yyyy"));
Вот такие гении встречаются в нашей местности....
+165
static string GetRequestParam(string request)
{
string result="";
int i = 4;
for(char c=request[i];c!=' ';c=request[++i])
result+=c;
return result;
}
+161
String^ TDebug::GetCurrentThreadFunctionName(int CallFunctionIndex)
{
return (gcnew StackTrace(true))->GetFrame(CallFunctionIndex)->GetMethod()->ToString();
};
void TDebug::ShowCurrentFunctionName(void)
{
Windows::Forms::MessageBox::Show(GetCurrentThreadFunctionName(2));
};
Помоему, в Microsoft Visual Studio 2010 отладчик для С++\CLI давно есть. :)
+116
namespace Containers
{
public class TBinaryWaitingQueue<TItem> where TItem : struct
{
private readonly TBinaryQueue<TItem> _queue;
TBinaryWaitingQueue(int amountOfitem)
{
_queue = new TBinaryQueue<TItem>(amountOfitem);
}
public void Enqueue(TItem[] items)
{
throw new NotImplementedException();
}
public void Enqueue(TItem[] items, int beginItem, int amountOfItem)
{
throw new NotImplementedException();
}
public void Dequeue(TItem[] items, int beginItem, int amountOfItem)
{
throw new NotImplementedException();
}
public TItem[] Dequeue(int amountOfItem)
{
throw new NotImplementedException();
}
}
}
Досталось в наследство от предков. Этому коду уже года 4.
+118
public class TWriteableForEach
{
public delegate void TForEachDelegate<TItem>(TItem item);
public static void Exec<TItem>(IList<TItem> itemsCollection, TForEachDelegate<TItem> forEachDelegate)
{
for (int i = 0; i < itemsCollection.Count(); ++i)
forEachDelegate(itemsCollection[i]);
}
} ;
Велосипед с квадратными колёсами?
+116
public class TObjects
{
public delegate T DeferredConstruction<out T>();
public static void Dispose<T>(ref T objectForDispose)
{
var typeOfObjectForDispose = typeof(T);
if (!typeOfObjectForDispose.IsClass)
DisposeIfIDisposable(ref objectForDispose, typeOfObjectForDispose);
else
if (!Equals(objectForDispose, null))
DisposeIfIDisposable(ref objectForDispose, typeOfObjectForDispose);
objectForDispose = default(T);
//objectForDispose = (T)(object)(null);
}
public static void Create<T>(ref T objectForCreate, DeferredConstruction<T> newObject)
{
Dispose(ref objectForCreate);
objectForCreate = newObject();
}
private static void DisposeIfIDisposable<T>(ref T objectForDispose, Type typeOfObjectForDispose)
{
bool canDisposable = (objectForDispose as IDisposable) != null;
if (canDisposable)
{
var dispose = typeOfObjectForDispose.GetMethod("Dispose");
dispose.Invoke(objectForDispose, new object[] { });
}
}
}
+162
<?php
$door[0]=$arResult["NAME"];
while($ob = $res->GetNextElement()){
$arFields = $ob->GetFields();
$door[]=$arFields["NAME"];
}
$door= array_unique($door);
$model = implode(",", $door);
$model_polotna = explode(",", $model);
$sz = sizeof($model_polotna);
for ($i=0; $i<=$sz; $i++){?>
<option id="<?echo $i;?>" value="<? echo $model_polotna[$i];?>"><?echo $model_polotna[$i];?></option>
<?}?>
Сайт на битриксе...