- 1
- 2
- 3
- 4
- 5
- 6
private bool trap = false;
public bool TrapExceptions
{
get { return this.trap; }
set { this.trap = true; }
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+7
private bool trap = false;
public bool TrapExceptions
{
get { return this.trap; }
set { this.trap = true; }
}
Выхода нет.
+2
bool compareArrays(int[] a,int[] b)
{
if(a.Length != b.Length)
return false;
for(int i = 0;i<a.Length;i++)
if(a[i] != b[i])
return false;
return true;
}
Нобелевская премия по программированию
+2
if ( LIKELY( _mode == normal ))
_mode задается один раз в начале программы по конфигурационному файлу.
+7
static int[] Compute(int[] array)
{
int count = array.Length;
int[] result = new int[count];
for (int i = 0, j = 0, mul = 1; i < count; ++i, j = 0, mul = 1)
{
for (; j != i; ++j)
mul *= array[j];
for (++j; j != count; ++j)
mul *= array[j];
result[i] = mul;
}
return result;
}
Ибо нефиг писать такие шарпи у for
−2
float PriceByProductID(string product_id)
{
if(product_id == RUBY_PILE)
return 1.99f;
else if (product_id == RUBY_BAG)
return 4.99f;
else if (product_id == RUBY_SACK)
return 9.99f;
else if (product_id == RUBY_BOX)
return 19.99f;
else if (product_id == RUBY_CHEST)
return 39.99f;
else if (product_id == RUBY_TRUNK)
return 99.99f;
else if (product_id == GOLD_PILE)
return 0.99f;
else if (product_id == GOLD_BAG)
return 2.99f;
else if (product_id == GOLD_SACK)
return 7.99f;
else if (product_id == GOLD_BOX)
return 14.99f;
else if (product_id == GOLD_CHEST)
return 29.99f;
else if (product_id == GOLD_TRUNK)
return 79.99f;
return 0f;
}
+3
/*
=============
TempVector
This is just a convenience function
for making temporary vectors for function calls
=============
*/
float *tv (float x, float y, float z)
{
static int index;
static vec3_t vecs[8];
float *v;
// use an array so that multiple tempvectors won't collide
// for a while
v = vecs[index];
index = (index + 1)&7;
v[0] = x;
v[1] = y;
v[2] = z;
return v;
}
+4
static const int s_extend_offset[16] = { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
Это я нашел в libJPG (они там в конец двинулись сдвигать отрицательные числа)
+1001
'used strict'
Уже "попользовался" strict
Оригинал: https://github.com/tischenkoa/portfolio-front-end-javascript/blob/master/24_task_(Ajax_loading_comics)/loadimg.js#L4
−85
local sol_lines = {}
local i = 1; local j = 0;
while (i <= solution:len()) do
local begin_pos = i
while(i <= solution:len() and solution:sub(i, i) ~= '\n') do
i = i + 1
end
if i > solution:len() then
i = solution:len()
end
local cur_line = solution:sub(begin_pos, i)
sol_lines[j] = trim(cur_line)
i = i + 1
j = j + 1
end
Lua
Как я разбивал строку на отдельные линии. Вместо того, чтобы использовать string.find(s, "\n", i + 1). Так я писал код 0.027397 года назад назад.
+144
$testing[$i]['ddate'] = ((substr("$departureDate", 0, -4)) . "/" . (substr("$departureDate", -4, 2)) . "/" . (substr("$departureDate", -2))) . "(" . ((substr("$departureTime", 0, -2)) . ":" . (substr("$departureTime", -2))) . ")";
$testing[$i]['adate'] = ((substr("$arrivalDate", 0, -4)) . "/" . (substr("$arrivalDate", -4, 2)) . "/" . (substr("$arrivalDate", -2))) . "(" . ((substr("$arrivalTime", 0, -2)) . ":" . (substr("$arrivalTime", -2))) . ")";
из реального проекта, который писал индус.
форматирование даты. это все еще и в цикле