- 1
- 2
- 3
function deleteCookie(name, path, domain) {
if (getCookie(name)) document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-1970 00:00:00 GMT';
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
function deleteCookie(name, path, domain) {
if (getCookie(name)) document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-1970 00:00:00 GMT';
}
...
+131
/*
=====================
Q_acos
the msvc acos doesn't always return a value between -PI and PI:
int i;
i = 1065353246;
acos(*(float*) &i) == -1.#IND0
This should go in q_math but it is too late to add new traps
to game and ui
=====================
*/
Астрологи объявили неделю Деда Лайна - количество говнокода и костылей увеличилось вдвое.
−119
echo `getent passwd | awk -F: '{ if($1 == "myaut") print $3; }'`
Определяет id пользователя myaut. Откопано в старой (моей) переписке. Эх...
+65
public class Path {
private String path;
private char winSep = '\\';
private char unixSep = '/';
public void set(String path){
if(!path.endsWith(File.separator)){
path.concat(File.separator);
}
this.path = path;
if(File.separatorChar == winSep && path.charAt(0) == unixSep){
this.path = path.replace(unixSep, winSep).substring(1);
}
}
public String get(){
String path = new String(this.path);
return path;
}
public String getRoot(){
String root = null;
if(File.separatorChar == unixSep){
root = "/";
}
if(File.separatorChar == winSep){
root = this.path.substring(0, this.path.indexOf(winSep)+1);
}
return root;
}
}
в 6 йаве нету класса Path, пришлось самому делать костыль-велосипед. тут где-то ошибочка есть, пока не смотрел.
+129
product:
.LFB34:
.cfi_startproc
xor eax, eax
test esi, esi
je .L7
lea eax, [rsi-1]
mov edi, edi
add rax, 1
imul rax, rdi
.L7:
rep
ret
.cfi_endproc
Оптимизациия умножения через рекурсию. Сишный код:
inline unsigned long int product_0(const unsigned int a, const unsigned int b, const unsigned long int tmp)
{
if (b == 0) return tmp;
return product_0(a, b-1, tmp+a);
}
unsigned long int product(const unsigned int a, const unsigned int b)
{
return product_0(a, b, 0);
}
−155
CASE WHEN ((b.k_vts_pre = null) OR (b.k_vts_goz_pre = null) OR (b.k_vts_relative_pre = null)) THEN null ELSE (b.k_vts_pre + b.k_vts_goz_pre + b.k_vts_relative_pre)/3 END
Один наш сотрудник проявил старание, достойное лучшего применения. В PostgreSQL можно так сравнивать с NULL, если настройка transform_null_equals=on. Но, во-первых, она у нас, как и по умолчанию, off, а во-вторых, зачем вообще?
+77
float tlen = sqrtf(top[0]*top[0]+top[1]*top[1]+top[2]*top[2]);
Всё в мире тлен и безысходность. В том числе и код.
+11
const listee* const nullablya = static_cast<listee*>(lst1);
if(nullablya == NULL)
+137
q = Convert.ToString(a.ToString() + b.ToString() + c.ToString() + d.ToString() + f.ToString() + g.ToString() + h.ToString() + j.ToString() + k.ToString() + l.ToString());
int a = int.Parse(textBox2.Text[0].ToString());
int b = int.Parse(textBox2.Text[1].ToString());
int c = int.Parse(textBox2.Text[2].ToString());
int d = int.Parse(textBox2.Text[3].ToString());
int f = int.Parse(textBox2.Text[4].ToString());
int g = int.Parse(textBox2.Text[5].ToString());
int h = int.Parse(textBox2.Text[6].ToString());
int j = int.Parse(textBox2.Text[7].ToString());
int k = int.Parse(textBox2.Text[8].ToString());
int l = int.Parse(textBox2.Text[9].ToString());
Random rnd = new Random();
int a = rnd.Next(0, 2);
int b = rnd.Next(0, 2);
int c = rnd.Next(0, 2);
int d = rnd.Next(0, 2);
int f = rnd.Next(0, 2);
int g = rnd.Next(0, 2);
int h = rnd.Next(0, 2);
int j = rnd.Next(0, 2);
int k = rnd.Next(0, 2);
int l = rnd.Next(0, 2);
private void DoWork(int a, int b, int c, int d, int f, int g, int h, int j, int k, int l)
private void ResetState()
{
pictureBox5.Visible = false;
pictureBox6.Visible = false;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
pictureBox2.Visible = false;
pictureBox3.Visible = false;
pictureBox4.Visible = false;
pictureBox10.Visible = false;
pictureBox11.Visible = false;
pictureBox12.Visible = false;
pictureBox13.Visible = false;
pictureBox14.Visible = false;
pictureBox15.Visible = false;
pictureBox16.Visible = false;
pictureBox17.Visible = false;
pictureBox18.Visible = false;
pictureBox19.Visible = false;
pictureBox20.Visible = false;
pictureBox27.Visible = false;
pictureBox28.Visible = false;
pictureBox29.Visible = false;
pictureBox31.Visible = false;
pictureBox32.Visible = false;
pictureBox33.Visible = false;
pictureBox34.Visible = false;
pictureBox35.Visible = false;
pictureBox36.Visible = false;
pictureBox30.Visible = false;
label2.Visible = false;
label4.Visible = false;
textBox2.Clear();
textBox1.Clear();
}
if (((b == 0 && (a == 1)) || ((b == 0) && (a == 0)) || ((b == 1) && (a == 0)) || ((b == 1) && (a == 1))))
{
if ((b == 0) && (pictureBox3.Visible)) { pictureBox6.Visible = Enabled; }
if ((b == 0) && (pictureBox2.Visible)) { pictureBox5.Visible = Enabled; }
if ((b == 1) && (pictureBox2.Visible)) { pictureBox6.Visible = Enabled; pictureBox4.Visible = Enabled; }
if ((b == 1) && (pictureBox3.Visible)) { pictureBox5.Visible = Enabled; pictureBox4.Visible = Enabled; }
}
//желательно чтоб здесь была пауза
if (((c == 0 && (pictureBox5.Visible)) || ((c == 0) && (pictureBox6.Visible)) || ((c == 1) && (pictureBox5.Visible)) || ((c == 1) && (pictureBox6.Visible))))
{
if ((c == 0) && (pictureBox5.Visible)) { pictureBox7.Visible = Enabled; }
if ((c == 0) && (pictureBox6.Visible)) { pictureBox8.Visible = Enabled; }
if ((c == 1) && (pictureBox5.Visible)) { pictureBox8.Visible = Enabled; pictureBox29.Visible = Enabled; }
if ((c == 1) && (pictureBox6.Visible)) { pictureBox7.Visible = Enabled; pictureBox29.Visible = Enabled; }
}
//желательно чтоб здесь была пауза
if (((d == 0 && (c == 1)) || ((d == 0) && (c == 0)) || ((d == 1) && (c == 0)) || ((d == 1) && (c == 1))))
{
if ((d == 0) && (pictureBox7.Visible)) { pictureBox9.Visible = Enabled; }
if ((d == 0) && (pictureBox8.Visible)) { pictureBox10.Visible = Enabled; }
if ((d == 1) && (pictureBox7.Visible)) { pictureBox10.Visible = Enabled; pictureBox30.Visible = Enabled; }
if ((d == 1) && (pictureBox8.Visible)) { pictureBox9.Visible = Enabled; pictureBox30.Visible = Enabled; }
}
+1009
mExpanded = onExpandClick ? !mExpanded : mExpanded;