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

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

    +165

    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
    case  KEY_F9: {
    			if ( !strcmp( chlist->gettype(), "ethernet" ) ) {
    				/* Редактор канала Ethernet */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "/m.cfg", buf );
    				//
    				tethcfgedit* edit = new tethcfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gprs" ) ) {
    				/* Редактор канала GPRS */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgprscfgedit* edit = new tgprscfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gsm" ) ) {
    				/* Редактор канала GSM */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgsmcfgedit* edit = new tgsmcfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gsppp" ) ) {
    				/* Редактор канала GS (пакетный) */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgspppcfgedit* edit = new tgspppcfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "gs" ) ) {
    				/* Редактор канала GS (прямой) */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tgscfgedit* edit = new tgscfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "radio" ) ) {
    				/* Редактор канала радиомодема */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tradiocfgedit* edit = new tradiocfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(),"cbs" ) ) {
    				/* Редактор канала Ethernet */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR,"",buf );
    				//
    				tcbscfgedit* edit=new tcbscfgedit( getscr(),buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			} else if ( !strcmp( chlist->gettype(), "ptsn" ) ) {
    				/* Редактор канала GSM */
    				char buf[0x100];
    				chlist->gen_path_chan( CHANCONFDIR, "", buf );
    				//
    				tptsncfgedit* edit = new tptsncfgedit( getscr(), buf );
    				edit->layer = layer;
    				edit->Run();
    				delete edit;
    			}
    ......

    Кусок case'a, где запускается редактор настроек соотвествующего канала связи. Код из одной встроенной железки.

    vollmond, 11 Сентября 2010

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    /**
    	     	 * Устанавливаем настройки соединения, по хорошему этого здесь не должно быть :)
    	     	 * считайте это костылём
    	     	 */
            	$oDbSimple->query("set character_set_client='utf8'");
            	$oDbSimple->query("set character_set_results='utf8'");
            	$oDbSimple->query("set collation_connection='utf8_bin'");

    Зато честно =) Взято из LiveStreet, файл Database.class.php

    hybroid, 02 Сентября 2010

    Комментарии (53)
  4. Си / Говнокод #3428

    +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
    #include<stdio.h>
    int main()
    {
    	int a;
    	printf("Vvedite svoy vozrast (0-200 let)");
    	scanf("%d",&a);
    	if ((a==11)||(a==12)||(a==13)||(a==14)){printf("mne %d let",a); return 0;}
    	if ((a==111)||(a==112)||(a==113)||(a==114)){printf("mne %d let",a); return 0;}
    	if (a%10==1){printf("mne %d god",a); return 0;}
    	if (a%10==2){printf("mne %d goda",a); return 0;}
    	if (a%10==3){printf("mne %d goda",a); return 0;}
    	if (a%10==4){printf("mne %d goda",a); return 0;}
    	if ((a%10==0)||(a%10==5)||(a%10==6)||(a%10==7)||(a%10==8)||(a%10==9)){printf("mne %d let",a); return 0;}
    	return 0;
    }

    Программа выводит год/года/лет. То есть возраст синтаксически правильно. Вопрос. Это как-нибудь можно написать покороче? Это считается говнокодом?

    ForEveR, 09 Июня 2010

    Комментарии (53)
  5. C# / Говнокод #3338

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public partial class Form1 : Form
        {
            string str;
            int количество;
            public Form1(string str, int количество)
            {
                InitializeComponent();
                str = this.str;
                количество = this.количество;
            }

    Классный конструктор, ничего не скажешь.
    А потом сидишь и удивляешься, почему же у тебя пустая строка и количество не прописалось...

    alexanika, 28 Мая 2010

    Комментарии (53)
  6. C# / Говнокод #27553

    0

    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
    static public (int, int) FirstPosition(int figure, int rotate)
            {
                int x = 0;
                int y = 0;
                if ((figure == 1) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 1) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 2) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 2) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 3) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 3) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 4) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 2)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 4)) { x = 6; y = 3; }
                if ((figure == 5) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 5) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 5) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 5) && (rotate == 4)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 1)) { x = 6; y = 3; }
                if ((figure == 6) && (rotate == 2)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 4)) { x = 6; y = 2; }
                if ((figure == 7) && (rotate == 1)) { x = 6; y = 3; }
                return (x, y);
            }                           //НАЧАЛЬНАЯ ПОЗИЦИЯ ЦЕНТРА ФИГУРЫ
            static public int[,] Position(int figure, int rotate, int[,] a, int x, int y)
            {
                if ((figure == 1) && (rotate == 1)) { a[x, y - 2] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 1) && (rotate == 2)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 2, y] = 1; }
                if ((figure == 2) && (rotate == 1)) { a[x - 1, y - 1] = 1; a[x - 1, y] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 2) && (rotate == 2)) { a[x - 1, y] = 1; a[x, y] = 1; a[x, y - 1] = 1; a[x + 1, y - 1] = 1; }
                if ((figure == 3) && (rotate == 1)) { a[x + 1, y - 1] = 1; a[x + 1, y] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 3) && (rotate == 2)) { a[x - 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 4) && (rotate == 1)) { a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; a[x + 1, y + 1] = 1; }
                if ((figure == 4) && (rotate == 2)) { a[x + 1, y] = 1; a[x, y] = 1; a[x - 1, y] = 1; a[x - 1, y + 1] = 1; }
                if ((figure == 4) && (rotate == 3)) { a[x - 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 4) && (rotate == 4)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y - 1] = 1; }
                if ((figure == 5) && (rotate == 1)) { a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; a[x - 1, y + 1] = 1; }
                if ((figure == 5) && (rotate == 2)) { a[x - 1, y - 1] = 1; a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 5) && (rotate == 3)) { a[x + 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 5) && (rotate == 4)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y + 1] = 1; }
                if ((figure == 6) && (rotate == 1)) { a[x, y] = 1; a[x, y - 1] = 1; a[x - 1, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 6) && (rotate == 2)) { a[x, y - 1] = 1; a[x + 1, y] = 1; a[x, y + 1] = 1; a[x, y] = 1; }
                if ((figure == 6) && (rotate == 3)) { a[x - 1, y] = 1; a[x, y + 1] = 1; a[x + 1, y] = 1; a[x, y] = 1; }
                if ((figure == 6) && (rotate == 4)) { a[x, y - 1] = 1; a[x - 1, y] = 1; a[x, y + 1] = 1; a[x, y] = 1; }
                if ((figure == 7) && (rotate == 1)) { a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y - 1] = 1; a[x, y - 1] = 1; }
                return (a);
            }             //ПОСТРОЕНИЕ ФИГУРЫ ОТНОСИТЕЛЬНО ЕЁ ЦЕНТРА

    Поворот тетрисных фигур

    VladimirM4K, 08 Августа 2021

    Комментарии (52)
  7. Python / Говнокод #27419

    +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
    from enum import Enum
    from dataclasses import dataclass
    
    class Pathfind:
        __init__ = lambda self, maxmoves=9999: exec(f'self.maxmoves={maxmoves}')
        def pathfind(self, cells):
            i, found, ecords, path = 0, False, (0,0), list()
            while(not found):
                a = self.getbyval(cells, i)
                for n in [j for sub in [self.filterneighbors(self.getneighbors(cells, x[0], x[1])) for x in a] for j in sub]:
                    cells[n.ccoords[1]][n.ccoords[0]].value = i+1 if cells[n.ccoords[1]][n.ccoords[0]].value>(i+1) else cells[n.ccoords[1]][n.ccoords[0]].value
                    if cells[n.ccoords[1]][n.ccoords[0]].ctype == CellType.END: found, ecords = True, (n.ccoords[1],n.ccoords[0])
                if i<self.maxmoves: i+=1
                else: return False
            found, cpath = False, ecords
            while(not found):
                path.append(cpath)
                if cpath == self.getbyval(cells, 0)[0]: return path
                cell = list(filter(None, ([x if x.value==cells[cpath[0]][cpath[1]].value-1 else None for x in self.filterneighbors(self.getneighbors(cells, cpath[0], cpath[1]))])))[0]
                cpath = (cell.ccoords[1],cell.ccoords[0])
                
        listtocells = lambda self, lst: [[Cell(CellType(lst[y][x]), (x,y), 0 if lst[y][x]==2 else self.maxmoves) for x in range(len(lst[y]))] for y in range(len(lst))]
        getbyval = lambda self, cells, val: [(x, y) for x in range(len(cells)) for y in range(len(cells[x])) if cells[x][y].value == val]
        getneighbors = lambda self, cells, x, y: list(filter(None, [cells[x-1][y] if x>0 else None,cells[x+1][y] if x<len(cells)-1 else None,cells[x][y-1] if y>0 else None,cells[x][y+1] if y<len(cells[x])-1 else None]))
        filterneighbors = lambda self, cells: list(filter(lambda cell: False if (cell is None) or cell.ctype==CellType.WALL else True, cells))
    
    class CellType(Enum):
    	AIR, WALL, START, END = 0, 1, 2, 3
    
    @dataclass
    class Cell:
        ctype: CellType = CellType.AIR
        ccoords: tuple = (0,0)
        value: int = 0

    Максимально уёбищная реализация волнового алгоритма.

    Gehennom, 11 Мая 2021

    Комментарии (52)
  8. JavaScript / Говнокод #27109

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $(".mobile-filter__footer-popular-btn").on("click",function(e){
    e.preventDefault(),
    $("#header-mobile").addClass("blue"),
    $(this).addClass("active"),
    $("#filter-aside-mobile-category-popular").addClass("active")
    });
    $("#filter-aside-mobile-category-popular .catalog-mobile-menu__close").on("click",function(e){
    e.preventDefault(),
    $("#header-mobile").removeClass("blue"),
    $(".mobile-filter__footer-popular-btn").removeClass("active"),
    $("#filter-aside-mobile-category-popular").removeClass("active")
    })

    sdf

    snegoviktlt, 12 Ноября 2020

    Комментарии (52)
  9. PHP / Говнокод #27035

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // https://vk.com/login?u=2&to=YWxfZmVlZC5waHA-
    $ echo YWxfZmVlZC5waHA- | base64 -d
    al_feed.phpbase64: invalid input
    
    $ echo -n al_feed.php | base64
    YWxfZmVlZC5waHA=

    Олимпиадники даже base64 умудрились пропатчить

    Fike, 17 Октября 2020

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

    +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
    Definition uilv_add_trivial {N} te (t : list TE) (traces : Traces N)
                 i j (Ht : MInt_ trace_elems_don't_commute j true traces t)
                 s s' (Hls : LongStep s (te :: t) s')
                 (Htriv : trivial_add i j traces) :
        MInt_ trace_elems_don't_commute i true (push_te traces i te) (te :: t).
      Proof with autorewrite with vector; eauto with vector; try vec_forall_eq_contradiction.
        unfold push_te.
        unfold trivial_add in Htriv.
        destruct (Fin.eq_dec i j) as [Hij|Hij].
        (* [i=j], solving by constructor: *)
        { subst.
          unfold trivial_add.
          eapply mint_keep with (rest := traces[@j])...
        }
        remember traces[@j] as t2_.
        destruct t2_ as [|te2 t2]; subst.
        { inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont];
            subst.
          - eapply mint_keep with (prog := true)...
            eapply mint_nil...
          - rewrite Hj in Heqt2_.
            discriminate.
        }
        remember traces[@i] as t1_.
        destruct t1_ as [|te1 t1]; subst.
        (* [te] is the last element in i-th trace: *)
        { eapply mint_keep with (rest := []) (prog := false)...
          inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont];
            subst...
          rewrite Heqt1_ in *.
          eapply mint_switch...
          rewrite <-Heqt1_...
        }
        destruct Htriv as [|[Hij' Hcomm]]; [contradiction Hij|idtac].
        eapply mint_keep with (rest := te1 :: t1) (prog := false)...
        rewrite Heqt1_, Vec.replace_id.
        inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont]; subst...
        replace te0 with te2 in * by congruence.
        eapply mint_switch...
        rewrite <-Heqt1_...
      Defined.

    Кто сказал, что хуже C++ темплейтов ничего уже нет? Вы ничего не понимаете в метушне. Это говно разворачивается в 12000 строк, например.

    CHayT, 20 Августа 2020

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

    −3

    1. 1
    2. 2
    Официальный тред для обсуждения способов высера видеоизображения на телеящик.
    Один калмент -- один способ

    Официальный тред для обсуждения способов высера видеоизображения на телеящик.
    Один калмент -- один способ

    MAPTbIwKA, 11 Декабря 2019

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