- 1
- 2
- 3
- 4
- 5
- 6
- 7
private static final double[][][] charsets = {{
{1, 2, 3, 4},
// 30 lines of a 3-dimentional array (4x9x3) declaration skipped
}}
// Later on
double dx = charsets[order[n[0]][i - 1]][n[i]][j];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+73
private static final double[][][] charsets = {{
{1, 2, 3, 4},
// 30 lines of a 3-dimentional array (4x9x3) declaration skipped
}}
// Later on
double dx = charsets[order[n[0]][i - 1]][n[i]][j];
Ну что тут еще скажешь... Legacy code forever!
−862
-- находим текущий месяц
FOR rec IN
SELECT date_part ('month', now()) as ma, date_part ('year', now()) as ya
LOOP
m1 = rec.ma-1;
IF m1=0 THEN m1=12; END IF;
Y1 = rec.ya;
IF m1=12 THEN Y1 = rec.ya - 1; END IF;
END LOOP;
FOR rec IN
SELECT count(v.partner_id) as cnt
FROM v, a where v.id=a.id and period like '%'||m1||'-'||Y1||' по%' and accepted = 1 and active=1
LOOP
-- вырезано
-- а десятком строк ниже
-- находим предыдущие 3 месяца
m2 = m1 - 1;
IF m2 = 0 THEN m2 = 12; END IF;
IF m1<m2 THEN Y2 = Y1 - 1; ELSE Y2 = Y1; END IF;
m3 = m2 - 1;
IF m3 = 0 THEN m3 = 12; END IF;
IF m2<m3 THEN Y3 = Y2 - 1; ELSE Y3 = Y2; END IF;
m4 = m3 - 1;
IF m4 = 0 THEN m4 = 12; END IF;
IF m3<m4 THEN Y4 = Y3 - 1; ELSE Y4 = Y3; END IF;
из кода доставшегося по наследству.
вот так вот видимо модно проводить поиск по дате
комментерии добавлены при выкладывании сюда
+68
def InvoicedExtra(JobExtra extra) {
type = extra.type
clientPrice = extra.price ?: ZERO
vatPrice = (extra.type.vatBand?.band ?: 0) * extra.price / 100
grossPrice = vatPrice ?: ZERO + clientPrice ?: ZERO
}
Мой код на Groovy. Обратите внимание на строку 5. Это типа хитрый способ суммирования который не бросает NullPointerException. Однако не учтены приоритеты операторов. Оцените красоту выстрела в ногу =)
+1001
struct Dir {
Dir(const char* name) {
d = opendir("/var/log");
}
~Dir();
const char* next();
bool operator== (DIR* other);
private:
DIR* d;
};
...
Dir var_log("/var/log");
+141
for (int x=0; x < TANK_SIZE; x++)
{
for (int y=0; y < TANK_SIZE; y++)
{
*((Uint32 *)(((Uint8 *)player_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * player_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * player_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * player_surface[LEFT]->pitch + y * player_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[RIGHT]->pixels) + x * player_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * player_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)player_surface[UP]->pixels) + y * player_surface[UP]->pitch + x * player_surface[UP]->format->BytesPerPixel));
*((Uint32 *)(((Uint8 *)enemy_surface[DOWN]->pixels) + (TANK_SIZE - y - 1) * enemy_surface[DOWN]->pitch + (TANK_SIZE - x - 1) * enemy_surface[DOWN]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[LEFT]->pixels) + (TANK_SIZE - x - 1) * enemy_surface[LEFT]->pitch + y * enemy_surface[LEFT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[RIGHT]->pixels) + x * enemy_surface[RIGHT]->pitch + (TANK_SIZE - y - 1) * enemy_surface[RIGHT]->format->BytesPerPixel)) = *((Uint32 *)(((Uint8 *)enemy_surface[UP]->pixels) + y * enemy_surface[UP]->pitch + x * enemy_surface[UP]->format->BytesPerPixel));
}
}
+132
if ((strlen == 0) && (key ==BNS_CLR_K || key ==WISE_K_BSPACE))
;
else
+130
#if defined (CAMCORDER_FEATURE_SUPPORT_VIEW_MODE)
// case SETTING_VIEW_MODE:
#endif
+136
if(TouchRegist && !gIsCleanView && !gChangeZoom &&!gChangeBrightness)
if( TouchRegist && gChangeZoom)
{
...
}
break;
+1005
void bvnr(char *text)
{
for(int f=0; f<=strlen(text); f++)
{
switch(text[f])
{
case 'Q' : text[f] = 'q' ; break;
case 'W' : text[f] = 'w' ; break;
case 'E' : text[f] = 'e' ; break;
case 'R' : text[f] = 'r' ; break;
case 'T' : text[f] = 't' ; break;
case 'Y' : text[f] = 'y' ; break;
case 'U' : text[f] = 'u' ; break;
case 'I' : text[f] = 'i' ; break;
case 'O' : text[f] = 'o' ; break;
case 'P' : text[f] = 'p' ; break;
case 'A' : text[f] = 'a' ; break;
case 'S' : text[f] = 's' ; break;
case 'D' : text[f] = 'd' ; break;
case 'F' : text[f] = 'f' ; break;
case 'G' : text[f] = 'g' ; break;
case 'H' : text[f] = 'h' ; break;
case 'J' : text[f] = 'j' ; break;
case 'K' : text[f] = 'k' ; break;
case 'L' : text[f] = 'l' ; break;
case 'Z' : text[f] = 'z' ; break;
case 'X' : text[f] = 'x' ; break;
case 'C' : text[f] = 'c' ; break;
case 'V' : text[f] = 'v' ; break;
case 'B' : text[f] = 'b' ; break;
case 'N' : text[f] = 'n' ; break;
case 'M' : text[f] = 'm' ; break;
)
}
}
Перевод текста в нижний регистр. Можно пугать детей на ночь))
+132
oSqlStr[0, 12] = " '<DIV onclick=\"fShowWindow(''../ReglamSchemesDoc.aspx?code='+Cast(s1.n_pp AS VarChar(50))+''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxemaRed.gif\"></DIV>'+CASE WHEN s1.s_reglament>'' THEN '<DIV onclick=\"fShowFile('''+Replace(Replace(s1.s_reglament,' ',''),';',''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxema.gif\"></DIV><DIV onclick=\"fShowFile(''')+''')\" align=\"center\"><img border=\"0\" src=\"../Image/sxema.gif\"></DIV>' ELSE '' END ";
Однострочная каша из трёх языков
Взято отсюда...
http://www.aspnetmania.com/Forums/ForumMessage/336926.html