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

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

    +175.2

    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
    $arr = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
      $result = $mysql->query("SELECT `upload` FROM `images` WHERE `upload` > '".(time()-60*60*24)."' AND `deleted` = '0' ORDER BY `upload` ASC");
      while($row = mysql_fetch_array($result))
      {
        switch($row['upload'])
        {
          case (($row['upload'] > (time()-60*60*24)) && ((time()-60*60*23) > $row['upload'])):
          $arr['23']++;
          break;
          case (($row['upload'] > (time()-60*60*23)) && ((time()-60*60*22) > $row['upload'])):
          $arr['22']++;
          break;
          case (($row['upload'] > (time()-60*60*22)) && ((time()-60*60*21) > $row['upload'])):
          $arr['21']++;
          break;
          case (($row['upload'] > (time()-60*60*21)) && ((time()-60*60*20) > $row['upload'])):
          $arr['20']++;
          break;
          case (($row['upload'] > (time()-60*60*20)) && ((time()-60*60*19) > $row['upload'])):
          $arr['19']++;
          break;
          case (($row['upload'] > (time()-60*60*19)) && ((time()-60*60*18) > $row['upload'])):
          $arr['18']++;
          break;
          case (($row['upload'] > (time()-60*60*18)) && ((time()-60*60*17) > $row['upload'])):
          $arr['17']++;
          break;
          case (($row['upload'] > (time()-60*60*17)) && ((time()-60*60*16) > $row['upload'])):
          $arr['16']++;
          break;
          case (($row['upload'] > (time()-60*60*16)) && ((time()-60*60*15) > $row['upload'])):
          $arr['15']++;
          break;
          case (($row['upload'] > (time()-60*60*15)) && ((time()-60*60*14) > $row['upload'])):
          $arr['14']++;
          break;
          case (($row['upload'] > (time()-60*60*14)) && ((time()-60*60*13) > $row['upload'])):
          $arr['13']++;
          break;
          case (($row['upload'] > (time()-60*60*13)) && ((time()-60*60*12) > $row['upload'])):
          $arr['12']++;
          break;
          case (($row['upload'] > (time()-60*60*12)) && ((time()-60*60*11) > $row['upload'])):
          $arr['11']++;
          break;
          case (($row['upload'] > (time()-60*60*11)) && ((time()-60*60*10) > $row['upload'])):
          $arr['10']++;
          break;
          case (($row['upload'] > (time()-60*60*10)) && ((time()-60*60*9) > $row['upload'])):
          $arr['9']++;
          break;
          case (($row['upload'] > (time()-60*60*9)) && ((time()-60*60*8) > $row['upload'])):
          $arr['8']++;
          break;
          case (($row['upload'] > (time()-60*60*8)) && ((time()-60*60*7) > $row['upload'])):
          $arr['7']++;
          break;
          case (($row['upload'] > (time()-60*60*7)) && ((time()-60*60*6) > $row['upload'])):
          $arr['6']++;
          break;
          case (($row['upload'] > (time()-60*60*6)) && ((time()-60*60*5) > $row['upload'])):
          $arr['5']++;
          break;
          case (($row['upload'] > (time()-60*60*5)) && ((time()-60*60*4) > $row['upload'])):
          $arr['4']++;
          break;
          case (($row['upload'] > (time()-60*60*4)) && ((time()-60*60*3) > $row['upload'])):
          $arr['3']++;
          break;
          case (($row['upload'] > (time()-60*60*3)) && ((time()-60*60*2) > $row['upload'])):
          $arr['2']++;
          break;
          case (($row['upload'] > (time()-60*60*2)) && ((time()-60*60*1) > $row['upload'])):
          $arr['1']++;
          break;
          case ($row['upload'] > (time()-60*60*1)):
          $arr['0']++;
          break;
        }
      }

    график :)

    Bodia, 01 Февраля 2010

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

    +175.1

    Розовый пони

    Возвращение розового пони

    pinkpony, 04 Декабря 2009

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

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function json2array($json_data)
    {
        $json_array = false;
        $json = substr($json, 1, -1);
        $json = str_replace(array(":", "{", "[", "}", "]"), array("=>", "array(", "array(", ")", ")"), $json_data);
        @eval("\$json_array = array({$json});");
        return $json_array;
    }

    Парсим json

    acer_paser, 01 Июня 2015

    Комментарии (60)
  5. Куча / Говнокод #16757

    +175

    1. 1
    http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/xeon-e3-1200v3-spec-update.pdf

    http://www.anandtech.com/show/8376/intel-disables-tsx-instructions-erratum-found-in-haswell-haswelleep-broadwelly
    На этот раз мне зогплатила амд, и принёс вам почитать.

    3.14159265, 24 Сентября 2014

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

    +175

    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
    $select_from = false;
    		if ($_GET['news_id']){
    			$this_id = (int)htmlspecialchars($_GET['news_id']);
    			$select_from = "news";
    		}
    		if ($_GET['article_id']){
    			$this_id = (int)htmlspecialchars($_GET['article_id']);
    			$select_from = "articles";
    		}
    		if ($_GET['articles_id']){
    			$this_id = (int)htmlspecialchars($_GET['articles_id']);
    			$select_from = "articles";
    		}
    		
    		$w = mysql_fetch_assoc(mysql_query("SELECT * FROM `".$getdata['pref'].$select_from."` WHERE `id` = \"{$this_id}\" LIMIT 1"));

    good_web_master, 27 Февраля 2014

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

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(!$item["region"])
    	$item["region"] = "Москва";
    
    	if($item["region"])
    	$text = str_replace('<option>'.$item["region"].'</option>', '<option value="'.$item["region"].'" selected>'.$item["region"].'</option>', $text);

    Гениальнейшая простановка selected для выбранного option в форме

    kindofbear, 27 Февраля 2014

    Комментарии (9)
  8. C# / Говнокод #12008

    +175

    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
    public static IEnumerable<float> Single(float from, float to, float step)
            {
                if (step <= 0.0f) step = (step == 0.0f) ? 1.0f : -step;
     
                if (from <= to)
                {
                    for (float f = from; f <= to; f += step) yield return f;
                }
                else
                {
                    for (float f = from; f >= to; f -= step) yield return f;
                }
            }
     
    public static IEnumerable<double> Double(double from, double to, double step)
            {
                if (step <= 0.0) step = (step == 0.0) ? 1.0 : -step;
     
                if (from <= to)
                {
                    for (double d = from; d <= to; d += step) yield return d;
                }
                else
                {
                    for (double d = from; d >= to; d -= step) yield return d;
                }
            }

    Такие методы накопированы для всех типов данных, которые известны поциенту.
    Но особо интересны эти джва метода

    Unlike some other programmimg languages (notably F#), C# doesn't have any built-in support for dealing with ranges of numbers. The .NET Framework does have the Enumerable.Range() method.
    - It can only deal with Int32's.
    - You can't specify a 'step' from one element of the range to the next. In effect, the step is always one. In this article, I'd therefore like to present a static Range class to deal with these deficiencies.

    http://www.c-sharpcorner.com/uploadfile/b942f9/dealing-with-ranges-of-numbers-in-C-Sharp

    3.14159265, 26 Октября 2012

    Комментарии (4)
  9. Куча / Говнокод #11979

    +175

    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
    with Ada.Integer_Text_Io, Ada.Text_Io;
    use Ada.Integer_Text_Io, Ada.Text_Io;
    
    procedure Test is
    v : Long_Float := 26.0;
    v1 : float := 26.0;
    begin
       while (v<27.0) loop
             Put_Line("Value = " & Long_Float'image(v));
            v:=v+0.2;
       end loop;
       while (v1<27.0) loop
             Put_Line("Value = " & float'image(v1));
            v1:=v1+0.2;
       end loop;
    
    end;

    ideone.com/pXIhvY
    Безопасный военный язык, да.

    3.14159265, 23 Октября 2012

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

    +175

    1. 1
    2. 2
    while ($new_width>$maxwidth) { $new_width *= 0.99; $new_height *= 0.99; }	
    	  while ($new_height>$maxheight) { $new_width *= 0.99; $new_height *= 0.99; }

    Мега код из сайта написанного на InstantCMS
    Вот так там уменьшаются картинки под максимальный размер...

    3xdimon, 26 Января 2012

    Комментарии (13)
  11. PHP / Говнокод #9222

    +175

    1. 1
    2. 2
    3. 3
    // Вопрос: Как быстро и наименее затратно для памяти\процессора проверить пустой ли каталог?
    // Один из ответов:
    if(rmdir($dir)) echo 'Была пустая директория.';

    bot-minurast, 25 Января 2012

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