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

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

    +132

    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
    format PE GUI
    entry start
    
    section '.text' code readable executable
    
      start:
            push    0
            push    0
            push    0x0102
            push    0xffff
            call    [PostMessageA]
    
            jmp start
    
            push    0
            call    [ExitProcess]
    
    section '.data' data readable writeable
    
    section '.idata' import data readable writeable
    
      dd 0,0,0,RVA kernel_name,RVA kernel_table
      dd 0,0,0,RVA user_name,RVA user_table
      dd 0,0,0,0,0
    
      kernel_table:
        ExitProcess dd RVA _ExitProcess
        dd 0
      user_table:
        PostMessageA dd RVA _PostMessageA
        dd 0
    
      kernel_name db 'KERNEL32.DLL',0
      user_name db 'USER32.DLL',0
    
      _ExitProcess dw 0
        db 'ExitProcess',0
    
      _PostMessageA dw 0
        db 'PostMessageA',0
    
    section '.reloc' fixups data readable discardable       ; needed for Win32s

    А вот таким нехитрым кодом на FASM'e мы намертво вешаем всю винду до перезагрузки или выхода из системы (по ctrl+alt+del). Ну и, опять-таки, кладем большой и толстый на UAC.

    gost, 25 Марта 2014

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

    +132

    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
    template <typename T>class CleverPtr
    {
      T* ptr;
    public:
      ~CleverPtr () { delete ptr; }
    
      CleverPtr () : ptr(new T) {}
    
     CleverPtr(const CleverPtr& other) 
        :ptr(new T)    // <--- если напрягает, используйте делегирующий конструктор с++11
      {
        operator =(other); 
      }
    
      CleverPtr& operator = (const CleverPtr& other) 
      {
        if (this != &other)
           *ptr = *other.ptr;
         return *this;
      }
     
    };

    оттуда

    LispGovno, 20 Февраля 2014

    Комментарии (31)
  4. C# / Говнокод #14517

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    var yetUsed = new HashSet<int>(startFrom ?? new int[] { })
    /*..............................................................................................................................*/
    foreach (var ind in Enumerable.Range(0, proxy.Size).Where(yetUsed.Contains))
         {
         proxy.SetIndexes(yetUsed.Where(x=>x!= ind).OrderBy(x => x).ToArray());
                               /* ............................................................................*/
         }
    /*.......................................................................................................................*/

    Из разряда
    int i = 3;
    "3" == i.ToString();

    andrewiv, 07 Февраля 2014

    Комментарии (0)
  5. Си / Говнокод #14379

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    rc = system
       (
       "test "
       "`ls -1 $WORKDIR/somedir/ | wc -l` = 1"
       " -a "
       "`ls -1 $WORKDIR/somedir/*/somefiles.* | wc -l` = 1"
       );
    ASSERTM( rc != -1, "check for number of <dirs>" );
    ASSERTM( rc == 0, "number of <some> files is greater than 1" );

    по мотивам http://govnokod.ru/14374

    из теста. да, можно было на С написать. да, мне было просто лень.

    Dummy00001, 17 Января 2014

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

    +132

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    procedure tmythread.execute;
    var i:integer;
    begin
      bot.postnumber:=topicno; bot.proxy:='220.181.89.72:8000'; bot.login:=copy(vote,1,pos(':',vote)-1); bot.password:=copy(vote,pos(':',vote)+1,length(vote));
      case actiontype of
        ac_dec:
        begin
          bot.comment:=false;
          try
            bot.connect;
          except
            terminate;
          end;
          bot.VoteAgainst;
        end;
        ac_inc:
        begin
          bot.comment:=false;
          try
            bot.connect;
          except
            terminate;
          end;
          bot.VoteOn;
        end;
        ac_deccurrent:
        begin
          bot.comment:=true;
          try
            bot.connect;
          except
            terminate;
          end;
          bot.VoteAgainst;
        end;
        ac_inccurrent:
        begin
          bot.comment:=true;
          try
            bot.connect;
          except
            terminate;
          end;
          bot.VoteOn;
        end;
        ac_decall:
        begin
          bot.comment:=true;
          try
            bot.connect;
          except
            terminate;
          end;
          for i:=0 to clist.Count-1 do
          begin
            bot.postnumber:=clist[i];
            bot.VoteAgainst;
          end;
        end;
        ac_incall:
        begin
          bot.comment:=true;
          try
            bot.connect;
          except
            terminate;
          end;
          for i:=0 to clist.Count-1 do
          begin
            bot.postnumber:=clist[i];
            bot.VoteOn;
          end;
        end;
        ac_decallc:
          begin
          bot.comment:=true;
          try
            bot.connect;
          except
            terminate;
          end;
          for i:=0 to clist.Count-1 do
          begin
          bot.postnumber:=clist[i];
          bot.VoteAgainst;
          end;
        end;
        ac_incallc:
          begin
          bot.comment:=true;
          try
            bot.connect;
          except
            terminate;
          end;
          for i:=0 to clist.Count-1 do
          begin
          bot.postnumber:=clist[i];
          bot.VoteOn;
          end; end; end; end;

    Код Того-На-Кого-Не-Будем-Показывать-Пальцем

    ВНИМАНИЕ! Некоторые строки были объединены дабы вместиться в пост

    kegdan, 22 Декабря 2013

    Комментарии (100)
  7. Pascal / Говнокод #14129

    +132

    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
    procedure tnewthread.checkfiles; // процедура выполняется в потоке
    var
      i:integer;
      status:tstatus;
      ptmp:array of char;
      temp:string;
      len:integer;
      fstream:tfilestream;
    begin
      flist.Clear;
      findfiles(findpath);
      for i:=flist.Count-1 downto 0 do
      begin
        status:=s_ok;
        try
          try
            fstream:=tfilestream.Create(flist[i],fmopenread);
            fstream.Position:=0;
            setlength(ptmp,fstream.size);
            fstream.Read(pointer(ptmp)^,fstream.size);
          except
            status:=s_error;
          end;
        finally
          fstream.free;
        end;
        temp:=string(pchar(ptmp));
        temp:=stringreplace(temp,'&nbsp;',' ',[rfreplaceall]);
        temp:=stringreplace(temp,'&gt;','>',[rfreplaceall]);
        temp:=stringreplace(temp,'&nbsp;',' ',[rfreplaceall]);
        temp:=stringreplace(temp,'&lt;','<',[rfreplaceall]);
        temp:=stringreplace(temp,'&amp;','&',[rfreplaceall]);
        temp:=stringreplace(temp,'&quot;','"',[rfreplaceall]);
        temp:=stringreplace(temp,'&copy;',#169,[rfreplaceall]);
        temp:=stringreplace(temp,#10,#13#10,[rfreplaceall]);
        Len := Length(temp);
        try
          try
            fstream:=tfilestream.Create('C:\1.txt',fmcreate); // заменил в целях теста, не помогает.
            fstream.Position:=0;
              fstream.WriteBuffer(temp[1], Len); // в этом  месте поток вылетает с ошибкой "Range check error"
          except
            status:=s_error;
          end;
        finally
          fstream.free;
        end;
        if status=s_ok then
        begin
          addfileinfo(flist[i]); 
          shrecyclefile(flist[i]);
        end
        else
        begin
          adderrinfo(flist[i]); // синхронизируемся с мемо и добавляем в него красную строчку с именем файла
          shmovefile(flist[i],erroroutputpath +'\' + extractfilename(flist[i])); // перемещаем файл в директорию с файлами, при обр. которых произошла ошибка
        end;
      end;
    end;

    Процедура для обработки текстовых файлов. Имеем дремлющий поток, залоченный waitsingleobject, который будит
    таймерная функция, если в папке есть по крайней мере 1 файл. т.е. одновременно к файлам обращается 1 поток.
    При разлочивании поток немедленно начинает заполнять лист именами файлов, после чего начинает прогонять их
    через процедуру-обработчик. Но вот беда - возникает ошибка range check error. причем возникает только в доп.потоке -
    вне потока все работает нормально. Товарищи ,не подскажете, в чем лажа? (

    Stertor, 24 Ноября 2013

    Комментарии (38)
  8. Куча / Говнокод #13967

    +132

    1. 1
    2. 2
    СТАВЬ ЛАЗАНЬЮ ЛЮКСЕНБУРГ ЛЕЙС ЛОЙС ЛАЙК ЛАВАНДЫШ ЛАПШУ ЛЕЙКАПЛАСТЫРЬ ЛАРУКРОФТ ЛУГАНСК ЛАНТАНОЙД ИЛЕ У ТИБЯ
    БУДАПЕШТ БАГЕТ БАГОР БАМБАЛЕЙЛА БАГРАТИОН БАТРУДИНАФ БАРАБИТ БУЛКА БИШКЕК

    СТАВЬ МНЕ ЛАЙК КАРОЧ ИЛЕ ТЫ ЛАЛКА С ГАРЯЩИМ ПУКАНОМ АЗАЗАЗАЗАЗАЗАШЩЗВШАЫВГАЛДВЫОАЛВЫОАРАРА)) 00)0)))нульскопка

    PragramistOtBoga, 18 Октября 2013

    Комментарии (32)
  9. Си / Говнокод #13467

    +132

    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
    #define max    0x08         //Max number of samples to average/filter
    #define byte unsigned char
    #define word unsigned int
    #define dword unsigned long
    
    #define FILTER 0
    #define AVG 1
    
    typedef struct  {
      word  reading[max];
      word  result[max];
    } ResultStct;
    
    
    static ResultStct x;
    static char samp = 0;//filter;
    const byte filter_mode = FILTER;
    
    extern int avg_result;
    
    void MYfilter(word input_sample) 
    {
      byte j;
      dword X;
        
    	x.reading[samp] = input_sample;
      
    	if(samp>0){
    
    		X=0;
    		for (j=0;j<=samp;j++){
    		  X += x.reading[j];
    		}
    		avg_result = (X >> 3) - 0x0200;
    		
    	} 
       
    	// Shift array of results if we hit max
    	if (samp >= max-1) {
    		for (j=0;j<max-1;j++){
    			x.result[j]  = x.result[j+1];
    			x.reading[j] = x.reading[j+1];
    		}
    		samp = max-1;
    	}
    	else 
    	{
    		samp++;
    	} //end if (i => max)

    Такой вот МОЩНЕЙШИЙ фильтр встретился в одном проекте.

    _113, 24 Июля 2013

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

    +132

    1. 1
    ТОП ТРАЛ КАРОЧ ЕДИТ АТДЫХАТЬ НА МОРЕ БУДУ ТАМ АКУЛ И МИДУЗ ТРАЛИРАВАТЬ))00 ОСЕНЬЮ ВЕРНУСЬ КАРОЧ))00 НЕ СКУЧАЙТИ ЛАЛКИ

    ТОП ТРАЛ КАРОЧ ЕДИТ АТДЫХАТЬ НА МОРЕ БУДУ ТАМ АКУЛ И МИДУЗ ТРАЛИРАВАТЬ))00 ОСЕНЬЮ ВЕРНУСЬ КАРОЧ))00 НЕ СКУЧАЙТИ ЛАЛКИ

    PragramistOtBoga, 17 Июля 2013

    Комментарии (0)
  11. Куча / Говнокод #13413

    +132

    1. 1
    У МИНЯ ЕСТЬ АЙФОН 5 И БАЛЬШОЙ ДОМ В МАЙНКРАВТЕ А ЧИВО ДАБИЛСЯ ТЫ?

    Я БАГАТ И УСПЕШОН

    PragramistOtBoga, 12 Июля 2013

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