1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #13713

    +12

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    // Вопрос: как сгенерировать в рантайме предупреждение от компилятора?
    // http://stackoverflow.com/q/4187967
    
       void f(int*p = nullptr)
        {
        if (!p)
    {
    //HERE I WOULD LIKE TO HAVE AN MSG THAT WOULD BE DISPLAYED DURING COMPILATION AS A WARNING POSSIBLY
    }
        }
    
    
    // Ответ: очевидно же, вызвать компилятор для соответствующего кода.
    // http://stackoverflow.com/a/4188155
    
    void f(int *p = nullptr) {
        if (!p) {
            system("gcc -Wall warning.c");
        }
    }

    Каков вопрос - таков ответ.

    Xom94ok, 01 Сентября 2013

    Комментарии (3)
  3. C# / Говнокод #13708

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    public void ConvertCross_2(int ch, string pfile,string NameSheet){
                //Преобразуем КроссТаблицу
                int Div = Convert.ToInt16(comboBox3.Text) - 1;
                string fn = ""; string fn1 = ""; string fn12 = ""; string fn13 = "";
                string fn14 = ""; string fn15 = ""; string fn16 = ""; string fn2 = "";
                string fn3 = "";
                string st = "";
                StreamWriter sw;
                string dirfile = "";
                if (textBox1.Text != ""){
                    dirfile = textBox1.Text + "\\" + pfile + ".csv";
                    if (ch == 1){
                        File.Delete(dirfile);
                    }
                    sw = new StreamWriter(dirfile, true, System.Text.Encoding.UTF8);
                }else{
                    if (ch == 1){
                        File.Delete(openFileDialog1.FileName + ".csv");
                    }
                    sw = new StreamWriter(openFileDialog1.FileName + ".csv", true, System.Text.Encoding.UTF8);
                }
                try{
                    for (int cl = 0; cl < 3 + Div; cl++){
                        fn = "F" + cl;
                        if (cl == 0){
                            st =  fn;
                        }else{
                            st += ";" +  fn ;
                        }
                    }
                    st += ";" +  "Sheets";
                    if (ch == 1){
                        sw.WriteLine(st);
                    }
                    for (int i = 1 + Div; i < dt.Columns.Count; i++){
                       Application.DoEvents();
                        for (int j = 1; j < dt.Rows.Count; j++){
                            fn1 = dt.Rows[j][0].ToString();
                            if (fn1 == "") fn1 = " ";
                            else fn1 = fn1.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            if (Div >= 1){
                                fn12 = dt.Rows[j][1].ToString();
                                if (fn1 == "") fn12 = " ";
                                else fn12 = fn12.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            }
                            if (Div >= 2){
                                fn13 = dt.Rows[j][2].ToString();
                                if (fn13 == "") fn13 = " ";
                                else fn13 = fn13.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            }
                            if (Div >= 3){
                                fn14 = dt.Rows[j][3].ToString();
                                if (fn14 == "") fn14 = " ";
                                else fn14 = fn14.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            }
                            if (Div >= 4){
                                fn15 = dt.Rows[j][4].ToString();
                                if (fn15 == "") fn15 = " ";
                                else fn15 = fn15.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            }
                            if (Div == 5){
                                fn16 = dt.Rows[j][5].ToString();
                                if (fn16 == "") fn16 = " ";
                                else fn16 = fn16.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            }
                            fn2 = dt.Rows[0][i].ToString();
                            if (fn2 == "") fn2 = " ";
                            else fn2 = fn2.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            fn3 = dt.Rows[j][i].ToString();
                            if (fn2 == "") fn2 = " ";
                            else fn2 = fn2.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            st =  fn1  + ";";
                            if (Div >= 1){
                                st = st +  fn12  + ";";
                            }
                            if (Div >= 2){
                                st = st +  fn13  + ";";
                            }
                            if (Div >= 3){
                                st = st +  fn14 + ";";
                            }
                            if (Div >= 4){
                                st = st + fn15 + ";";
                            }
                            if (Div >= 5){
                                st = st + fn16 + ";";
                            }
                            st = st +  fn2 +  ";" + fn3 + ";\"" + NameSheet.Replace("\n", "").Replace("\r", "").Replace(";", "SemicoloN");
                            if (fn3.Trim()!=""){
                               sw.WriteLine(st);
                            }
                        }
                    }
                    sw.Close();            
                }finally{
                    sw.Close();
            }
    }

    кто бы мог подумать, что так можно сделать unpivot

    Lokich, 30 Августа 2013

    Комментарии (3)
  4. PHP / Говнокод #13625

    +155

    1. 1
    return ((($dailyNum <= 15) && ($by2Month < 1) && ($monthlyNum <= 100) && ($DailyNik <= 15)) ? true : false);

    Кыщь, пыщь, выщь, хуищь

    dimkich, 19 Августа 2013

    Комментарии (3)
  5. PHP / Говнокод #13609

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    list($long_startIp, $long_endIp) = ip_range($value);
    $strange = long2ip($long_startIp);
    $endrange = long2ip($long_endIp);
    $addit[] = ('a.dst_ip BETWEEN ' . ip2long($strange) . ' AND ' . ip2long($endrange));

    Студенты нынче совсем тупые пошли.

    DrFreez, 15 Августа 2013

    Комментарии (3)
  6. Pascal / Говнокод #13595

    +87

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    *-*-*-*-*-*-*-*-*-*-*-*-*-*-зашифрованные прокси:*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    <TD id="address">
    <script language=javascript>
    <!--
    					proxy(3,'28','70','216','172',80);
    					proxy(4,'70','216','172','28',80);
    					proxy(1,'103','10','59','30',8080);
    					proxy(2,'10','59','30','103',80);
    					proxy(3,'251','151','101','109',80);
    					proxy(4,'83','209','222','25',8080);
    					proxy(1,'101','109','251','89',80);
    					proxy(2,'50','26','5','101',8080);
    					proxy(3,'220','89','186','93',8000);
    					proxy(4,'158','98','190','250',8090);
    					proxy(1,'92','39','185','18',80);
    					proxy(2,'8','240','44','5',8080);
    					proxy(3,'127','84','124','81',8080);
                                                           
                                                                   [...]
    // -->
    </script>
    				</TD>
    
    //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-Свиток-расшифровщик*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    
    function proxy(mode,arg1,arg2,arg3,arg4,port){
    	var ret;
    	switch(mode) {
    		case 1:
    			ret=arg1+"."+arg2+"."+arg3+"."+arg4+":"+port+"<BR>";
    			break;
    		case 2:
    			ret=arg4+"."+arg1+"."+arg2+"."+arg3+":"+port+"<BR>";
    			break;
    		case 3:
    			ret=arg3+"."+arg4+"."+arg1+"."+arg2+":"+port+"<BR>";
    			break;
    		case 4:
    			ret=arg2+"."+arg3+"."+arg4+"."+arg1+":"+port+"<BR>";
    			break;
    	}
    	document.write(ret);
    }
    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
    
    var
      StartPos : Integer;
      MyText ,temp: string;
      memorystream:tmemorystream;
      anolink:string;
      i:integer;
      ccount:integer;
      counter:string;
      endpos:integer;
      steg,eteg:string;
      b:integer;
      mode,arg1,arg2,arg3,arg4,port:string;
    begin
      steg:='proxy(';
      eteg:=');';
      memorystream:=tmemorystream.create;
      idhttp1.Request.UserAgent:='Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0';
      idhttp1.Request.Accept:='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
      idhttp1.request.AcceptLanguage:='ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3';
      idhttp1.Request.AcceptEncoding:='ngnix';
      idhttp1.Request.Connection:='keep-alive';
      idhttp1.Get('http://anonymousinet.com/index.php',memorystream);
      memorystream.Position:=0;
      mytext:=memorystreamtostring(memorystream);
      mytext:=utf8toansi(mytext);
      memorystream.Clear;
      startpos:=0;
      While true do
      begin
        startPos := PosEx(steg, MyText, StartPos + 1);
        if StartPos > 0 then
        begin
          temp:=copy(mytext,startpos+length(steg),length(mytext));
          b:=pos(eteg,temp);
          if b >0 then
          temp:=copy(temp,1,b-1);
          temp:=trim(temp);
          temp:=stringreplace(temp,'''','',[rfreplaceall]);
          mode:=stringfield(temp,',',1);
          arg1:=stringfield(temp,',',2);
          arg2:=stringfield(temp,',',3);
          arg3:=stringfield(temp,',',4);
          arg4:=stringfield(temp,',',5);
          port:=stringfield(temp,',',6);
          smemo1.lines.add(proxy(mode,arg1,arg2,arg3,arg4,port));
        end
        else
        Break;
      end;
    
        end;

    Зловонная попытка защитить прокси от парсинга. Гм, как бы помягче,гм, неудачная...

    Stertor, 11 Августа 2013

    Комментарии (3)
  7. C++ / Говнокод #13577

    +15

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    union AtomicIndx
    {
      struct { std::atomic<uint16> ReadCur, ReadMax, WriteCur, WriteMax; };
      struct { struct Idx { uint16 Cur, Max; }; std::atomic<Idx> Read, Write; };
      struct { struct Idx { uint16 ReadCur, ReadMax, WriteCur, WriteMax; }; std::atomic<Idx> All; };
    };
    static_assert(sizeof(AtomicIndx) == sizeof(uint64), "sizeof(AtomicIndx) != sizeof(uint64)");

    Мы все знаем откуда это.

    LispGovno, 08 Августа 2013

    Комментарии (3)
  8. PHP / Говнокод #13541

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    include_once('library.php');
    
    $query=mysql_fetch_row(mysql_query('SELECT MAX(id) FROM news'));
     
    $max_id=$query[0];
    //echo $max_id;
    //$query=mysql_fetch_row(mysql_query('SELECT MIN(id) FROM news'));
    $min_id=1;
     
    do{
        $query=mysql_fetch_row(mysql_query('SELECT id FROM news WHERE id='.$min_id.''));
       
        $query=$query[0];
       
        mysql_query('UPDATE news SET id='.++$query.' WHERE id='.$min_id.'');
       
        echo $query;
     
    }while($min_id++<$max_id);

    Апдейт всей таблицы: id = id + 1

    deep, 03 Августа 2013

    Комментарии (3)
  9. Pascal / Говнокод #13462

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    if x > 0 then 
    begin
    if y <= 0 then 
    begin
    if z <> 0 then 
    begin
    if x1 > 0 then 
    begin
    if y1 < 7 then 
    begin
    if z1 > 0 then 
    begin
    if z1 mod 5 = 0 then 
    begin
    if m <> 3 then 
    begin
    if n > 5 then 
    begin
    writeln('1');
    end;
    end;
    end;
    end;
    end;
    end;
    end;
    end;
    end;

    iNsectus, 21 Июля 2013

    Комментарии (3)
  10. PHP / Говнокод #13428

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($subletter) {
    	$firms = $db->getArray("SELECT `id_firm`, `id_service`, `id_city`, `name` FROM `firm` WHERE `id_city` IN (".implode(",", array_keys($cities)).") AND `name` REGEXP '^".mysql_real_escape_string($letter.$subletter)."' AND `blocked` = 0 ORDER BY name ASC");
    } 
    elseif ($letter) {
    	$firms = $db->getArray("SELECT `id_firm`, `id_service`, `id_city`, `name` FROM `firm` WHERE `id_city` IN (".implode(",", array_keys($cities)).") AND `name` REGEXP '^".mysql_real_escape_string($letter)."' AND `blocked` = 0 ORDER BY name ASC");
    }
    else $firms = array();

    gorky, 16 Июля 2013

    Комментарии (3)
  11. C++ / Говнокод #13390

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Дорогой участник! Не спеши покидать страницу. Я прошу тебя помочь:
    не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;
    минусуя других участников ты воспитываешь в себе чувство меры и помогаешь обществу снижать ЧСВ. 
    Заранее спасибо, друг мой. Ты будешь вознагражден за это деяние!
    
    Тот, кто покинул страницу, но не выполнил моей просьбы, умрет через 9 дней.

    Дорогой участник! Не спеши покидать страницу. Я прошу тебя помочь:
    не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;
    минусуя других участников ты воспитываешь в себе чувство меры и помогаешь обществу снижать ЧСВ.
    Заранее спасибо, друг мой. Ты будешь вознагражден за это деяние!


    Тот, кто покинул страницу, но не выполнил моей просьбы, умрет через 9 дней.

    Stertor, 11 Июля 2013

    Комментарии (3)