- 1
info.setCreatingDate(document.getREGDATE() != null ? document.getREGDATE() : null);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+82
info.setCreatingDate(document.getREGDATE() != null ? document.getREGDATE() : null);
из реального проекта
+100
$sql = "SELECT (SELECT Name FROM dbo.RoutesTypes WHERE RowID = Type) AS Name --Название маршрута
,(SELECT Name FROM dbo.Destinations WHERE Name = '$Src') AS DestA --Пункт отправления
,(SELECT Name FROM dbo.Destinations WHERE Name = '$Dst') AS DestB --Пункт назначения
--,(SELECT COUNT([RowID]) FROM [RoutePartInstances] WHERE [RoutePartType] = RoutesTypes.RowID AND [Occuped] = 0) AS FreePlaces --Количество свободных мест на выбранную часть маршрута
,(SELECT SUM(Cost) From RoutesParts WHERE Ordern >= RoutesTypes.OrderA AND Ordern <= RoutesTypes.OrderB AND InstanceID = Type) AS TicketCost --Стоимость билета на выбранную часть маршрута
,(SELECT SUM(TimeInWay) From RoutesParts WHERE Ordern >= RoutesTypes.OrderA AND Ordern <= RoutesTypes.OrderB AND InstanceID = Type) AS TimeInWay --Время в пути на выбранной части маршрута
--Расчёт времени отправления
,(SELECT DATEADD(Minute,
(SELECT
CASE
WHEN RoutesTypes.OrderA > 1 THEN (SELECT SUM(TimeInWay) From RoutesParts WHERE Ordern < RoutesTypes.OrderA AND InstanceID = Type)+10*(SELECT COUNT(RowID) From RoutesParts WHERE Ordern < RoutesTypes.OrderA AND InstanceID = Type)
ELSE 0
END),[DateStart])) AS DepartureTime
--Расчёт времени прибытия
,(SELECT DATEADD(Minute,
(SELECT SUM(TimeInWay) From RoutesParts WHERE Ordern >= RoutesTypes.OrderA AND Ordern <= RoutesTypes.OrderB AND InstanceID = Type)+10*(SELECT COUNT(RowID) From RoutesParts WHERE Ordern > RoutesTypes.OrderA AND Ordern <= RoutesTypes.OrderB AND InstanceID = Type),
(SELECT DATEADD(Minute,
(SELECT
CASE
WHEN RoutesTypes.OrderA > 1 THEN (SELECT SUM(TimeInWay) From RoutesParts WHERE Ordern < RoutesTypes.OrderA AND InstanceID = Type)+10*(SELECT COUNT(RowID) From RoutesParts WHERE Ordern < RoutesTypes.OrderA AND InstanceID = Type)
ELSE 0
END),[DateStart])))) AS ArrivalTime
--,RoutesTypes.OrderA --Порядок выбранной точки отправления в маршруте. Это нам понадобится при покупке билета
--,RoutesTypes.OrderB --Порядок выбранной точки назначания в маршруте. Это нам понадобится при покупке билета
--,RoutesTable.[RowID] AS RouteID --Идентификатор рейса из таблицы расписаний. Это нам понадобится при покупке билета
--,RoutesTable.[Type] AS RouteTypeID --Идентификатор типа маршрута из таблицы типов маршрутов. Это нам понадобится при покупке билета
FROM [RoutesTable] AS RoutesTable
INNER JOIN (SELECT RoutesParts_A.[InstanceID],RoutesParts_A.[TimeA],RoutesParts_B.TimeB,RoutesParts_A.RowID,RoutesParts_ A.Ordern AS OrderA,RoutesParts_B.Ordern AS OrderB
FROM [RoutesParts] AS RoutesParts_A
INNER JOIN (SELECT [InstanceID],[TimeB],[Ordern] FROM [RoutesParts] WHERE [DestBID] = (SELECT RowID FROM Destinations WHERE Name = '$Dst')) AS RoutesParts_B ON RoutesParts_B.InstanceID = RoutesParts_A.InstanceID
WHERE [DestAID] = (SELECT RowID FROM Destinations WHERE Name = '$Src'))AS RoutesTypes ON RoutesTable.Type = RoutesTypes.InstanceID";
Встретил на форуме phpforum.ru. Человек интересовался почему не работает запрос :)
+71
public int getLifeWidth() {
return cells == null ? 0 : cells.length;
}
public int getLifeHeight() {
return cells == null || cells.length == 0 || cells[0] == null ? 0 : cells[0].length;
}
private int _getLifeWidth() {
return cells.length;
}
private int _getLifeHeight() {
return cells[0].length;
}
есть ли мне оправдание? ))
+122
switch (count)
{
case 2:
return Tuple.Create(col[1]);
case 3:
return Tuple.Create(col[1], col[2]);
case 4:
return Tuple.Create(col[1], col[2], col[3]);
case 5:
return Tuple.Create(col[1], col[2], col[3], col[4]);
case 6:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6]);
case 8:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7]);
case 9:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], col[7]);
case 10:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8]));
case 11:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9]));
case 12:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9], col[10]));
case 13:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9], col[10], col[11]));
case 14:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9], col[10], col[11], col[12]));
default:
throw new ArgumentOutOfRangeException("count", count, "Can't convert array to tuple.");
}
+67
...
/*}*/
/*}*/
/*}*/
/*}*/
/*}*/
/*}*/
/*}*/
/*}*/
}
Скачал, посмотрел, офигел:D
+156
Запиши эти слова в файл (например, words.txt или slova.txt) и прочитай его с помощью функции fgetcsv().
<?php
$x=fopen("slova.txt","r");
$y=fgetcsv($x,filesize($x),' ');
foreach($y as $line)
{
echo $line;
};
?>
Разбиение строки на отдельные слова с сайта hashcode.ru
+134
зависающие маллок )))
void * __cdecl malloc(size_t size)
{
// No fail malloc!
void *pMem;
do {
pMem=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
if(pMem==NULL) Sleep(2000);
} while(pMem==NULL);
return pMem;
}
void * __cdecl operator new( unsigned int cb )
{
// No fail new!
void *pMem;
do {
pMem=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,cb);
if(pMem==NULL) Sleep(2000);
} while(pMem==NULL);
return pMem;
}
что хотел аффтар ? !!! аццкий сотона
int GetCfgBool(char *cfgstr,const char *key)
{
return GetCfgNum(cfgstr,key)?TRUE:FALSE;
}
аффтар застрелись !!!
char *GetCfgStr(char *cfgstr,const char *key)
{
char *str=cfgstr;
// Skip past name of options list
while(*str!='\0') str++;
str++;
// Walk through options
while(*str!='\0') {
int nLen;
if(*str=='B') {
nLen=1;
str+=2;
if(strncmp(str,key,strlen(key))==0) break;
} else if(*str=='S') {
str+=2;
nLen=atoi(str);
while(*str!=']') str++;
str+=2;
if(strncmp(str,key,strlen(key))==0) break;
} else if(*str=='N') {
str+=2;
char *pb;
pb=str;
while(*str!=',') str++;
nLen=(DWORD)str-(DWORD)pb;
str++;
pb=str;
while(*str!=']') str++;
int nLen2=(DWORD)str-(DWORD)pb;
if(nLen2>nLen) nLen=nLen2;
str+=2;
if(strncmp(str,key,strlen(key))==0) break;
}
while(*str!='=') str++;
str++;
str+=(nLen+1);
}
if(*str!='\0') {
while(*str!='=') str++;
return str+1;
}
return NULL;
}
исходники BO2K гениально !!!))
и как не стыдно ЭТО распространять
http://www.bo2k.com/
+116
int min = 32000;
int max = 0;
int mind = 0;
int i;
int j;
double t;
double f;
int p = 0;
double[] x = new double[4];
double[] k = new double[4]; //массив для К
double[,] s = { { 2, 4, 5, 1, 0, 0, 0 }, { 1, 8, 6, 0, 1, 0, 0 }, { 7, 4, 5, 0, 0, 1, 0 }, { 4, 6, 7, 0, 0, 0, 1 } };
double[,] a = { { 2, 4, 5, 1, 0, 0, 0 }, { 1, 8, 6, 0, 1, 0, 0 }, { 7, 4, 5, 0, 0, 1, 0 }, { 4, 6, 7, 0, 0, 0, 1 } };
double[] b = { 120, 280, 240, 360 };
double[] c = { 10, 14, 12, 0, 0, 0, 0 };
double[] r = new double[7];
double[,] s1 = new double[4, 7];
for ( i = 0; i < 4; i++)
{
for (j = 0; j < 7; j++)
Console.Write(a[i, j] + "\t");
Console.WriteLine("\n");
}
for (j = 0; j < 4; j++)
Console.Write(b[j] + "\t");
Console.WriteLine();
for (j = 0; j < 7; j++)
Console.Write(c[j] + "\t");
Console.WriteLine();
Console.WriteLine();
//первая итерация
for (i = 0; i < 4; i++)
{
for (j = 0; j < 7; j++)
{
if (a[i, j] != 0)
s[i, j] = b[i] / a[i, j];
Console.Write(s[i, j] + "\t");
}
Console.WriteLine();
}
for (j = 0; j < 7; j++)
{
for (i = 0; i < 4; i++)
{
if (s[i, j] < min)
min = Convert.ToInt32(s[i, j]);
}
r[j] = min * c[j];
Console.Write(r[j] + "\t");
}
Console.WriteLine();
for (j = 0; j < 7; j++)
{
if (r[j] > max)
{
max = Convert.ToInt32(r[j]);
p = j;
}
}
for (i = 0; i < 4; i++)
{
for (j = 0; j < 7; j++)
{
k[i] = a[i, p];
}
}
min = 32000;
for (i = 0; i < 4; i++)
{
if (s[i, p] < min)
{
min = Convert.ToInt32(s[i, p]);
mind = i;
}
Console.WriteLine();
}
t = a[mind, p];
for (i = 0; i < 4; i++)
{
for (j = 0; j < 7; j++)
{
s[i, j] = a[i, j];
}
}
Полная версия: http://pastebin.com/p36MWPXR
Этот код был выложен на одном из форумов с просьбой объяснить "Что делает приложенный код".
Посмотрев строчек 50 из почти 300, понял, что мои нервы дороже этого говнокода.
Форматирование практически полностью сохранено.
Был один интересный пост к этой теме: "могу ошибаться, но по-моему - позорит автора", согласен с мнением автора этого поста.
+152
$mem = c("memo1")->text;
$count =count($mem);
for($i=0;$i<$count;$i++)
{
list($mai[$i], $pass[$i]) = explode(":", $mem[$i]);
// чекаешь на валид как уже надо if( $mail[$i] == true and $pass[$i] == true) {code}
}
http://community.develstudio.ru/showthread.php/4745-Как-достать-текст-до-знака-quot-quot-и-после-знака-quot-quot-(делаю-чекер)
+110
// Loop through the list of passwords and try them until one works
for (; passwordcounter < passwords.Length; passwordcounter++)
{
//shit goes here
}
...another one.