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

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

    +23

    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
    struct S* gpS;
    
    struct S
    {
       // this class has no user-defined default ctor
       void *operator new (size_t size, void*p, int i)
       {
          ((S*)p)->i = i;   // ordinarily, should not initialize
                            // memory contents inside placement new
          return p;
       }
       int i;
    };

    Код с сайта майкрософт.

    LispGovno, 09 Января 2013

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

    +58

    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
    // Released Under Affero General Public License, Version 3 (AGPL3)
    // Author: [email protected]
    
    $result = "TRUE";
    
    $testable_string = strtolower($string_to_test);
    $testable_string_length = strlen($string_to_test);
    
    for($i_string = 0; $i_string < $testable_string_length; $i_string++)
    {
        $current_value_to_test = $testable_string[$i_string];
       
        if(    ($current_value_to_test != "0")        &&
            ($current_value_to_test != "1")        &&
            ($current_value_to_test != "2")        &&
            ($current_value_to_test != "3")        &&
            ($current_value_to_test != "4")        &&
            ($current_value_to_test != "5")        &&
            ($current_value_to_test != "6")        &&
            ($current_value_to_test != "7")        &&
            ($current_value_to_test != "8")        &&
            ($current_value_to_test != "9")        &&
            ($current_value_to_test != "a")        &&
            ($current_value_to_test != "b")        &&
            ($current_value_to_test != "c")        &&
            ($current_value_to_test != "d")        &&
            ($current_value_to_test != "e")        &&
            ($current_value_to_test != "f")        )
        {
            $result = "FALSE";
            $i_string = $testable_string_length;
        }
    }

    Смахивает на баян, но тем не менее.
    http://php.net/manual/ru/function.is-numeric.php, из комментов.

    RaZeR, 14 Декабря 2012

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

    +50

    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
    function StringForCountryInt($countryInt)
    	{
    		switch ($countryInt)
    		{
    			case "1" : return 'Afghanistan'; break;
                case "2" : return 'Albania'; break;
                case "3" : return 'Algeria'; break;
                case "4" : return 'American Samoa'; break;
                case "5" : return 'Andorra'; break;
                case "6" : return 'Angola'; break;
                case "7" : return 'Anguilla'; break;
                case "8" : return 'Antarctica'; break;
    //          ....
    //          ....
    //          ....
                 case "239" : return 'Zimbabwe'; break;
    		}
    	}

    MODx, evolution. Сниппет WebLoginPE.
    В базе сохраняет ID страну, в классе вот такой метод для обратного преобразования :)

    MaXL, 04 Декабря 2012

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

    +51

    1. 1
    2. 2
    3. 3
    4. 4
    $needMoreDataWM = ($exchange->getSumTo()->getCurrency()->getSystem()->getModule() == 'WebMoney' || $exchange->getSumFrom()->getCurrency()->getSystem()->getModule() == 'WebMoney') || $this->getRequest()->request->get('user_wmid');
    $needMoreDataWM = $needMoreDataWM && !$user->getWmid();
    $needMoreDataBank = ($exchange->getSumTo()->getCurrency()->getSystem()->getClass() == 'bank') && !$user->getVat() || $this->getRequest()->request->get('user_vat');
    $needMoreData = $needMoreDataBank || $needMoreDataWM || !($user->getFullname() && $user->getPassport()) || $this->getRequest()->request->get('user_fullname') || $this->getRequest()->request->get('user_passport');

    А что поделаешь, Doctrine принуждает

    nick4fake, 28 Ноября 2012

    Комментарии (17)
  6. Си / Говнокод #12197

    +133

    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
    #include<stdio.h>
    #include<math.h>
     
    int main()
    {
    long long a1,a2,a3,a4,t,p,l,m1,m,d1,d2,d3,d4,c1,c2,c3,c4,n,r;
    double po;
     
    m=1000000006;
    scanf("%lld",&t);
    while(t--)
         {scanf("%lld",&n);
         a1=1;a2=1;a3=1;a4=0;
         d1=1;d2=0;d3=0;d4=1;
         
         p=n-2;
    while(p>0)
         {    if(p%2!=0)
            { c1=((d1*a1)%m+(d3*a3)%m);
              c2=((d1*a2)%m+(d2*a4)%m);
              c3=((d3*a1)%m+(d4*a3)%m);
              c4=((d3*a2)%m+(d4*a4)%m);
              d1=c1;d2=c2;d3=c3;d4=c4;
            }
              c1=((a1*a1)%m+(a2*a3)%m);
              c2=((a1*a2)%m+(a2*a4)%m);
              c3=((a3*a1)%m+(a4*a3)%m);
              c4=((a3*a2)%m+(a4*a4)%m);
              a1=c1;a2=c2;a3=c3;a4=c4;
              p=p/2;
         }
     l=((d1*1)%m+(d2*1)%m)%m;m1=((d3*1)%m+(d4*1)%m)%m;
     
    po=pow(2,l);
    r=llrintl(po)%(m+1);
     
     
    printf("%lld\n",r);
    }
    return 0;
       }

    Fai, 26 Ноября 2012

    Комментарии (17)
  7. Куча / Говнокод #12036

    +124

    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
    Сайт ЦИК Украины, нынешние выборы народных депутатов. 
    http://cvk.gov.ua/vnd2012/wp300pt001f01=900.html
    Говно везде - html, css, дизайн, юзабилити. 
    
    Для начала цитаты из html-кода страницы. В шапке мы видим 
    заголовок "XHTML 1.0 Transitional", а в коде - конструкции 
    в стиле 90-х годов, например:
    
    <IMG src="img2012/bar-blue1.jpg" WIDTH=" 1" HEIGHT=20>
    
    <table class=t1 cellspacing=0><tr>
        <td width="50%" class="td2"><font class="f3"> © WWW ІАС "Вибори 
            народних депутатів України"
        <td align="right" class="td2"> 
    </table>
    
    <td class=td10 align=center><font color="maroon">2</font>
    <td class=td2><A class=a1 href="wp302pt001f01=900pf7171=52.html">
    політична партія Всеукраїнське об’єднання "Батьківщина"</A></td>
    
    В стилях тоже все в порядке, товарищи проявили 
    отличное знание спецификаций:
    ... height=14px; ...
    ... background-color: 666699; ...
    ... text-decoration: non ...
    ... background-color : none; ...
    ... valign: center; ...
    
    Про отсутствие смысла я даже не говорю. 
    Вот, например, такой перл:
    FONT.F1 {color: black; font-family:Arial;font-size: 14pt}

    Сайт ЦИК Украины. Не сомневаюсь, что ООО "НПП "Медирент"" и ООО "НПП "Проком" получили за свою работу сотни нефти.

    P.S. Плохо, что в самом говнокоде нельзя применять форматирование bb-тегами, для кучи было бы полезно.

    ZX_Spectrum, 31 Октября 2012

    Комментарии (17)
  8. Java / Говнокод #11985

    +74

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    public void aMethod() {
        try {
            int t = 0;
            t = t / t;
        } catch (Exception e) {
            System.out.println("aMethod");
            for (StackTraceElement element : e.getStackTrace()) {
                System.out.println("aMethod" + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber() );
            }
        }
    ...//дополнительная "логика"
    }

    оригинальный способ узнать кто же вызвал aMethod

    Cat4eg, 24 Октября 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var x = new { Items = new List<int> { 1, 2, 3 }.GetEnumerator() };
    while (x.Items.MoveNext())
    {
        Console.WriteLine(x.Items.Current);
    }

    http://ideone.com/Qzdki

    LispGovno, 16 Октября 2012

    Комментарии (17)
  10. C++ / Говнокод #11786

    +19

    1. 1
    Lennart lennart=new Lennart;

    Надпись жёлтым цветом на гпавном меню minecraft.

    dos_, 17 Сентября 2012

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

    +64

    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
    <?php
    $_1_2[1]="одна ";
    $_1_2[2]="две ";
     
    $_1_19[1]="один ";
    $_1_19[2]="два ";
    $_1_19[3]="три ";
    $_1_19[4]="четыре ";
    $_1_19[5]="пять ";
    $_1_19[6]="шесть ";
    $_1_19[7]="семь ";
    $_1_19[8]="восемь ";
    $_1_19[9]="девять ";
    $_1_19[10]="десять ";
     
    $_1_19[11]="одиннацать ";
    $_1_19[12]="двенадцать ";
    $_1_19[13]="тринадцать ";
    $_1_19[14]="четырнадцать ";
    $_1_19[15]="пятнадцать ";
    $_1_19[16]="шестнадцать ";
    $_1_19[17]="семнадцать ";
    $_1_19[18]="восемнадцать ";
    $_1_19[19]="девятнадцать ";
     
    $des[2]="двадцать ";
    $des[3]="тридцать ";
    $des[4]="сорок ";
    $des[5]="пятьдесят ";
    $des[6]="шестьдесят ";
    $des[7]="семьдесят ";
    $des[8]="восемдесят ";
    $des[9]="девяносто ";
     
    $hang[1]="сто ";
    $hang[2]="двести ";
    $hang[3]="триста ";
    $hang[4]="четыреста ";
    $hang[5]="пятьсот ";
    $hang[6]="шестьсот ";
    $hang[7]="семьсот ";
    $hang[8]="восемьсот ";
    $hang[9]="девятьсот ";
     
    $namerub[1]="гривна ";
    $namerub[2]="гривны ";
    $namerub[3]="гривен ";
     
    $nametho[1]="тысяча ";
    $nametho[2]="тысячи ";
    $nametho[3]="тысяч ";
     
    $namemil[1]="миллион ";
    $namemil[2]="миллиона ";
    $namemil[3]="миллионов ";
     
    $namemrd[1]="миллиард ";
    $namemrd[2]="миллиарда ";
    $namemrd[3]="миллиардов ";
     
    $kopeek[1]="копейка ";
    $kopeek[2]="копейки ";
    $kopeek[3]="копеек ";
    
    еще бред
    
    function num2str($L){
    global $_1_2, $_1_19, $des, $hang, $namerub, $nametho, $namemil, $namemrd, $kopeek;
    $s=" ";
    $s1=" ";
    $s2=" ";
    $kop=intval( ( $L*100 - intval( $L )*100 ));
    $L=intval($L);
    if($L>=1000000000){
        $many=0;
        semantic(intval($L / 1000000000),$s1,$many,3);
        $s.=$s1.$namemrd[$many];
        $L%=1000000000;
    }

    Привет :)
    Для многих сайтов, которые работают с числами (продажа товаров, например), то в чеке рекомендуется писать стоимость товара не только цифрами, но и буквами. :)
    Вот для этого и есть такой не большой скрипт на php. Это функция, которой удобно пользоваться.

    И так, вот что нам надо:
    - массив с переменными
    - две функции: одна подфункция - дополняет главную.

    Как пользоваться

    <?php

    $prop=num2str(121.45;
    echo $prop;

    ?>

    насладиться в полном объеме можно здесь: http://zvlad.com/180-vyvod-chislovoy-sumy.html

    ahref, 11 Сентября 2012

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