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

    В номинации:
    За время:
  2. Куча / Говнокод #11813

    +127

    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
    /**
       * Determines equality based upon the contents of this Box instead of the box itself.
       * As a result, it is not symmetric. Which means that for
       *
       * <pre name="code" class="scala">
       *     val foo = "foo"
       *     val boxedFoo = Full(foo)
       *     foo == boxedFoo //is false
       *     boxedFoo == foo //is true
       * </pre>
       *
       * For Full and Empty, this has the expected behavior. Equality in terms of Failure
       * checks for equivalence of failure causes.
       */
      override def equals(other: Any): Boolean = (this, other) match {
        case (Full(x), Full(y)) => x == y
        case (Full(x), y) => x == y
        case (x, y: AnyRef) => x eq y
        case _ => false
      }

    https://github.com/lift/framework/blob/master/core/common/src/main/scala/net/liftweb/common/Box.scala

    rat4, 20 Сентября 2012

    Комментарии (97)
  3. Куча / Говнокод #11787

    +127

    1. 1
    override def text: String = super.text

    https://github.com/scala/scala/blob/master/src/library/scala/xml/Node.scala

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

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

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <ul>
     <li><label><input class="smert_zaemchika" type="checkbox" /> Смерть заемщика</label></li>
     <li><label><input class="poterya_raboty" type="checkbox" /> Потеря работы</label></li>
     <li><label><input class="ne_nado" type="checkbox" /> Нет</label></li>
     </ul>

    не могу больше молчать......

    Mihard, 12 Сентября 2012

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

    +127

    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
    function name = monthName( m )
    
    switch m
        case 1
            name = 'Jan';
        case 2 
            name = 'Feb';
        case 3
            name = 'Mar';
        case 4
            name = 'Apr';
        case 5
            name = 'May';
        case 6
            name = 'Jun';
        case 7 
            name = 'Jul';
        case 8 
            name = 'Aug';
        case 9 
            name = 'Sep';
        case 10 
            name = 'Oct';
        case 11
            name = 'Nov';
        case 12 
            name = 'Dec';
    end

    MATLAB. Источник: http://berkeleyearth.org/results-summary/ - почитайте, что за проект. А ноги растут вот отсюда: http://www.sfgate.com/science/article/UC-climate-change-skeptic-changes-views-3748148.php

    Этот отрывок присутствует в двух файлах, я нашел его после беглого просмотра. Может быть, я ничего не понимаю в научных расчетах и совершенно незнаком с синтаксисом MATLAB, но есть у меня подозрения, что здесь что-то не так.

    Папки с тестами к коду я не нашел. Сижу вот, думаю...

    scriptin, 20 Августа 2012

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

    +127

    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
    $ cat macro.c
    # define M3(x, y, z) x + y + z
    # define M2(x, y) M3(x, y)
    # define P(x, y) {x, y}
    # define M(x, y) M2(x, P(x, y))
    M(a, b)
    
    $ gcc-4.5  -E  macro.c
    # 1 "macro.c"
    # 1 "<built-in>"
    # 1 "<command-line>"
    # 1 "macro.c"
    
    a + {a + b}
    $

    Какой выхлоп по разным версиям cl?
    Отсюда: http://stackoverflow.com/questions/11469462/difference-between-gcc-and-microsoft-preprocessor

    sayidandrtfm, 13 Июля 2012

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

    +127

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    static char[] decToBin(int n)
    {
        byte size = sizeof(int) * 8;
        char[] result = new char[size];
    
        for (int i = 0; i < size; i++) 
        {
            result[size - i - 1] = (((n >> i) & 1).ToString().ToCharArray()[0]);
        }
        return result;
    }

    Плохо пахнущий транслятор непосредственно в дополнительный код.

    vistefan, 12 Июня 2012

    Комментарии (7)
  8. Си / Говнокод #10595

    +127

    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
    if(!menu_font||!oboima_text||!info||!infoR||!infoD||!infoBR||
          !oblaka1_tex||!fon1_tex||!fon2_tex||!fon3_tex||
          !galka_tex||!galka_menu_tex||!strelka_menu_tex||!strelka_menu_D_tex||
          !znak_myasnik_tex||!znak_strelok_tex||!znak_razrushitel_tex||!znak_tehnik_tex||
          !status_opit_tex||!status_udar_tex||!status_status_tex||!opit_okno_vibora_tex||
          !okno_lvl_progress_tex||!okno_lvl_progress_red_tex||!okno_lvl_progress_green_tex||!okno_lvl_polzunok_tex||
          !snd||!ak_reload1||!ak_reload2||!pm_fire||!pm_reload1||!pm_reload2||
          !pp19_fire||!pp19_reload1||!pp19_reload2||!fn_f2000_fire||!tt_fire||
          !mac_fire||!mac_reload1||!mac_reload2||!webley_fire||!webley_reload1||!webley_reload2||!milkor_fire||
          !fn_five_seven_fire||!winch_fire||!drob_reload1||!drob_pompa||!vzriv_grena1||
          !rocket_fire||!rocket2_fire||!rocket_polet||!rocket2_polet||
          !myaso_upalo1||!myaso_upalo2||!myaso_upalo3||!myaso_upalo4||!myaso_upalo5||!myaso_upalo6||!myaso_upalo7||
          !myaso_upalo8||
          !myaso_razriv_user1||!myaso_razriv_user2||
          !menu_sound||!menu_choose||
          !shot1||!headshot1||!headshot2||!headshot3||!headshot4||!headshot5||!headshot6||!headshot7||!headshot8||
          !ssik1||!ssik2||!ssik3|!ssik4||
          !ptenec_death1||
          !ak||!ak2||!ak_upgraded||!ak2_upgraded||!w_pm_tex||!w_pp19_vityaz_tex||!w_fn_f2000_tex||!w_fn_f2000_upgraded_tex||
          !w_tt_tex||!w_rpk_tex||!w_mac_tex||
          !w_winchester_tex||!w_winchester_anime_tex||!w_rpk47_tex||!w_glok_tex||!w_glok2_tex||!w_rgd5_tex||!w_milkor_tex||
          !w_panzer_tex||!w_panzer_out_tex||!w_webley_tex||!w_fn_five_seven_tex||!w_granata_podstvol_tex||!w_granata_panzer_tex||
          !w_qlz87_pushka_tex||!w_qlz87_trenoga_tex||!katana_udar_sleva_tex||
          !blood1_tex||!blood2_tex||!blood3_tex||!blood_shot1_tex||
          !blood_plyam1_tex||!blood_plyam2_tex||!blood_plyam3_tex||!blood_luzha1_tex||
          !blood_myaso1_tex||!blood_myaso2_tex||!blood_myaso3_tex||!blood_myaso4_tex||!blood_myaso5_tex||
          !blood_zayac_noga1_tex||!blood_zayac_noga2_tex||!blood_zayac_noga3_tex||!blood_zayac_noga4_tex||
          !blood_zayac_rebra1_tex||!blood_zayac_rebra2_tex||
          !blood_vzriv1_a_tex||!blood_vzriv1_b_tex||!blood_vzriv1_c_tex||!blood_vzriv1_d_tex||!blood_vzriv1_e_tex||
          !blood_vzriv1_e2_tex||
          !player1_myasnik_gogranata_ruka1_tex||!player1_myasnik_gogranata_ruka2_tex||
          !player1_strelok_gogranata_ruka1_tex||!player1_strelok_gogranata_ruka2_tex||
          !player1_razrushitel_gogranata_ruka1_tex||!player1_razrushitel_gogranata_ruka2_tex||    
          !player1_tehnik_gogranata_ruka1_tex||!player1_tehnik_gogranata_ruka2_tex||
          !player1_myasnik_tex||!player1_strelok_tex||!player1_razrushitel_tex||!player1_tehnik_tex||
          !player1_myasnik_ruka1_udar_sleva_tex||!player1_strelok_ruka1_udar_sleva_tex||
          !player1_razrushitel_ruka1_udar_sleva_tex||!player1_tehnik_ruka1_udar_sleva_tex||
          !player1_myasnik_ruka1_pistol_tex||!player1_strelok_ruka1_pistol_tex||
          !player1_razrushitel_ruka1_pistol_tex||!player1_tehnik_ruka1_pistol_tex||
          !player1_myasnik_ruka1_vintovka_tex||!player1_strelok_ruka1_vintovka_tex||
          !player1_razrushitel_ruka1_vintovka_tex||!player1_tehnik_ruka1_vintovka_tex||
          !player1_myasnik_ruka1_winch_tex||!player1_strelok_ruka1_winch_tex||
          !player1_razrushitel_ruka1_winch_tex||!player1_tehnik_ruka1_winch_tex||
          !player2_strelok_tex||!player2_gogranata_ruka1_tex||!player2_gogranata_ruka2_tex||
          !player2_strelok_ruka1_udar_sleva_tex||!player2_strelok_ruka1_vintovka_tex||!player2_strelok_ruka1_pistol_tex||
          !zayac_go_tex||!zayac_uhi_k_tex||!zayac_uhi_s_tex||!zayac_uhi_tex||
          !zayac_boshka_tex||!zayac_boshka_bezuh_tex||
          !volk_go_tex||!volk_trup1_a_tex||!volk_trup1_b_tex||!volk_trup1_c_tex||
          !medved_go_tex||!medved_boshka1_tex||
          !medved_trup1_a_tex||!medved_trup1_b_tex||!medved_trup1_c_tex||!medved_trup1_d_tex||!medved_trup1_e_tex||!medved_trup1_f_tex||
          !medved_trup1_a_bezboshki_tex||!medved_trup1_b_bezboshki_tex||!medved_trup1_c_bezboshki_tex||
          !medved_trup1_d_bezboshki_tex||!medved_trup1_e_bezboshki_tex||!medved_trup1_f_bezboshki_tex||
          !ptenec_go_tex||!ptenec_wait_tex||!ptenec_vpolete_tex||!ptenec_vpolete_reverse_tex||!ptenec_trup1_tex||
          !ptenec_boshka_vzriv1_a_tex||!ptenec_boshka_vzriv1_b_tex||!ptenec_boshka_vzriv1_c_tex||
          !ptenec_boshka_vzriv1_d_tex||!ptenec_boshka_vzriv1_e_tex||
          !RPG_healer_tex||!RPG_illusionist_tex||!RPG_teleporter_tex||
          !bonus_shilo_tex||!bonus_this_tex||
          !bonus_shilo_text_tex||!bonus_this_text_tex||!bonus_daun_text_tex||!bonus_ulitka_text_tex||!bonus_umnik_text_tex||
          !bonus_shilo_status_tex||!bonus_daun_status_tex||!bonus_ulitka_status_tex||!bonus_umnik_status_tex||
          !zayac_trup1_a_tex||!zayac_trup1_b_tex||!zayac_trup1_c_tex||!zayac_trup1_d_tex||
          !zayac_trup1_a_bezuh_tex||!zayac_trup1_b_bezuh_tex||!zayac_trup1_c_bezuh_tex||!zayac_trup1_d_bezuh_tex||
          !zayac_trup1_a_bezboshki_tex||!zayac_trup1_b_bezboshki_tex||!zayac_trup1_c_bezboshki_tex||
          !zayac_trup1_d_bezboshki_tex||
          !zayac_go_bezuh_tex||!ogon1||
          !blood_ssit_tex||!RPG_healing_tex||!vzriv_grena_tex||!vzriv_ogon_grena_tex||
          !alkash1_tex||!derevo1_tex||!penek1_tex||
          !znak_polputi_tex||!polosa_finish_tex)

    Название проекта: ЩИ!!!Симулятор жестокости
    http://www.gamedev.ru/projects/forum/?id=160897

    Уверен, название выбиралось не только исходя из геймплея, но и из кода игры.

    greevex, 06 Июня 2012

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

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    # My first attempt in J:
    +/(>/)"1 <.@(10&^.)(2 & x:) (+%)/\(1x,1000$2)
    
    # It gave the right answer, but took about an hour.
    # Based on other people's comments I went back and figured out the relationship
    # between one answer and the next, and came up with this,
    # which runs in less than 1 second:
    ((((0{])+([:$[:":1{])>([:$[:":2{])),(1{]+2*2{]),1{]+2{])^:1000) 0 3x 2x

    http://projecteuler.net/thread=57;page=2


    Как на этом можно писать?

    TheHamstertamer, 04 Июня 2012

    Комментарии (19)
  10. Java / Говнокод #10356

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    pFirst = new LinePoints;
    pFirst->ptPixel.x = ptOrig.x*szStart.cx/15 + ptStart.x;
    pFirst->ptPixel.y = (15-ptOrig.y)*szStart.cy/15 + ptStart.y;
    pFirst->next = NULL;
    if(pFirst != NULL)
    {
        ...

    Ну а правда, вдруг NULL?

    someone, 24 Мая 2012

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

    +127

    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
    typedef struct _xjmp_stru {
        unsigned long Ebp;
        unsigned long Ebx;
        unsigned long Edi;
        unsigned long Esi;
        unsigned long Esp;
        unsigned long Eip;
    } xjmp_stru;
    
    typedef int xjmp_buf[6];
    
    __declspec(naked)
    int __cdecl xsetjmp(xjmp_buf)
    {
    	__asm
    	{
    		mov     edx, [esp+4]
    		mov     [edx], ebp
    		mov     [edx+4], ebx
    		mov     [edx+8], edi
    		mov     [edx+12], esi
    		mov     [edx+16], esp
    		mov     eax, [esp]
    		mov     [edx+20], eax
    		xor     eax, eax
    		ret
    	}
    } 
    
    
    __declspec(naked, noreturn)
    void __cdecl xlongjmp(xjmp_buf, int)
    {
    	__asm
    	{
    		mov     edx, [esp+4]
    		mov     ebp, [edx]
    		mov     ebx, [edx+4]
    		mov     edi, [edx+8]
    		mov     esi, [edx+12]
    		mov     eax, [esp+8]
    		test    eax, eax
    		jne     __
    		inc     eax
    __:      
    		mov     esp, [edx+16]
    		add     esp, 4
    		mov     edx, [edx+20]
    		jmp     edx
    	}
    } 
    
    int dummy(xjmp_buf jbuf)
    {
    	volatile int jk = 8;
    	if (jk)
    		xlongjmp(jbuf, 2);
    	else
    		return 7;
    }
    
    int main()
    {
    	xjmp_buf jbuf;
    	if (xsetjmp(jbuf))
    	{
    		puts("excpt");
    		return -1;
    	}
    	dummy(jbuf);
    	puts("great work");
    	return 0;
    }

    экая хренотень

    63F45EF45RB65R6VR, 13 Марта 2012

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