1. Куча / Говнокод #13413

    +132

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

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

    PragramistOtBoga, 12 Июля 2013

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

    +86

    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
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    procedure TForm1.Colorize;
    procedure SetStr(var s: string; const Style: TFontStyles; const Color, BackColor: Byte);
    var
      Format: TCharFormat2;
    begin
     If s<>'' Then
      begin
        FillChar(Format, SizeOf(Format), 0);
        Format.cbSize := SizeOf(Format);
        Format.dwMask:= CFM_BACKCOLOR or CFM_COLOR;
        Format.crBackColor:= GetIRCColor(BackColor, True);
        Format.crTextColor:= GetIRCColor(Color);
        if RichEdit1.HandleAllocated then
        SendMessage(RichEdit1.Handle, EM_SETCHARFORMAT, SCF_SELECTION,
          LPARAM(@Format));
        RichEdit1.SelAttributes.Style:= Style;
        RichEdit1.SelText:= s;
        RichEdit1.SelAttributes.Assign(RichEdit1.DefAttributes);
        s:= ''
      end;
    end;
    var
      Color, BackColor: Byte;
      Style: TFontStyles;
      CurrStr: string;
      I: Integer;
    begin
      Style:= [];
      Color:= DefForeColor;
      BackColor:= DefBackColor;
      CurrStr:= '';
      I:= 0;
      While (I<Length(Str))do
       begin
        Inc(I);
        case Str[I] of
          #31:
              begin
               SetStr(CurrStr, Style, Color, BackColor);
               If fsUnderLine in Style Then
                Exclude(Style, fsUnderLine)
               else
                Include(Style, fsUnderLine);
             end;
          #2:
             begin
               SetStr(CurrStr, Style, Color, BackColor);
               If fsBold in Style Then
                Exclude(Style, fsBold)
               else
                Include(Style, fsBold);
             end;
           #15, #13:
               begin
                SetStr(CurrStr, Style, Color, BackColor);
                Color:= DefForeColor;
                BackColor:= DefBackColor;
               end;
           #3:
              begin
                SetStr(CurrStr, Style, Color, BackColor);
                Inc(I);
                Color:= DefForeColor;
                If (Str[I] in ['0', '1'..'9'])Then
                 begin
                  Color:= StrToInt(Str[I]);
                  Inc(I);
                  If (Str[I] in ['0', '1'..'9'])Then
                   begin
                     Color:= StrToInt(IntToStr(Color)+Str[I]);
                     Inc(I)
                   end;
                 end;
                 If Str[I] = ',' Then                         //BackColor
                   begin
                    BackColor:= DefBackColor;
                    Inc(I);
                    If (Str[I] in ['0', '1'..'9'])Then
                     begin
                      BackColor:= StrToInt(Str[I]);
                      Inc(I);
                      If (Str[I] in ['0', '1'..'9'])Then
                       begin
                        BackColor:= StrToInt(IntToStr(BackColor)+Str[I]);
                        Inc(I)
                       end;
                      end;
                    end;
                   Dec(I) 
              end;
           else
            CurrStr:= CurrStr+Str[I]
        end;
       end;
       SetStr(CurrStr, Style, Color, BackColor);
    end;

    Процедура раскрашивающая текст из Log-файла mIRC загруженого в TRichEdit на форме.

    function GetIRCColor(const Color: Byte; const Back: Boolean=False): TColor;
    begin
    case Color of
    0: Result:= clWhite;
    1: Result:= clBlack;
    2: Result:= clNavy;
    3: Result:= clGreen;
    4: Result:= clRed;
    5: Result:= clMaroon;
    6: Result:= clPurple;
    7: Result:= $000080FF;
    8: Result:= clYellow;
    9: Result:= clLime;
    10: Result:= clTeal;
    11: Result:= clAqua;
    12: Result:= clBlue;
    13: Result:= clFuchsia;
    14: Result:= clGray;
    15: Result:= clSilver;
    else
    begin
    If Back Then
    Result:= clWhite
    else
    Result:= clBlack
    end;
    end;
    end;

    ASNightingale, 12 Июля 2013

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

    +11

    1. 1
    2. 2
    const listee* const nullablya = static_cast<listee*>(lst1);
    if(nullablya == NULL)

    LispGovno, 12 Июля 2013

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    list* down_if_valid_me(void)
    {
    	return this ? this->down() : NULL;
    }

    LispGovno, 12 Июля 2013

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

    +157

    1. 1
    2. 2
    3. 3
    if (is_array(reset((array)$patentInfo))) {
    // ...
    }

    quall, 12 Июля 2013

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

    +123

    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
    #include <malloc.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdint.h>
    
    typedef struct {
      char * begin;
      uint64_t size, data_size;
    } str_t;
    
    inline uint64_t max(uint64_t a, uint64_t b) {
      return (a > b) ? a : b;
    }
    
    inline str_t correct_data_size(str_t str, uint64_t new_size) {
      if(str.data_size < new_size) {
        str.data_size = (max(str.data_size, new_size) << 1);
        str.begin = realloc(str.begin, str.data_size);    
      }
      return str;
    }
    
    inline str_t concat(str_t dest, str_t src) {
      uint64_t new_size = (dest.size + src.size - 1);
      dest = correct_data_size(dest, new_size);
      memcpy((dest.begin + dest.size - 1), src.begin, src.size);
      dest.size = new_size;
      return dest;
    }
    
    inline str_t create_str(char * str, uint64_t size) {
      return (str_t){.begin = strcat(malloc(size), str), .size = size, .data_size = size};
    }
    
    inline void print_str_t(str_t str) {
      fprintf(stderr, "str = %ssize = %lu, data_size = %lu\n", str.begin, str.size, str.data_size);
    }
    
    uint64_t test(uint64_t star_n, uint64_t n, str_t str, str_t * gstr) {
      uint64_t end = (star_n + n);
      do {
        *gstr = concat(*gstr, str);
        
        char * pos = gstr->begin;
        while((pos = strstr(pos, "efgh")))
          memcpy(pos,"____",4);
        
      } while((++star_n) != end);
      return star_n;
    }
    
    int main(void) {
      char data[] = "abcdefghefghefgh";
      str_t str = create_str(data, sizeof(data)); 
      str_t gstr = create_str("", 1);
      time_t starttime = time(NULL);
      
      uint64_t block_c = 0;
      
      while((block_c = test(block_c, ((256/16) * 1024), str, &gstr)) != (((256/16) * 1024) * 20))
        printf("%ldsec\t\t%lukb\n",time(NULL)-starttime,gstr.size/1024);
      
    }

    Минимально оптимизированный вариант в царь-стиле теста из предыдущего ГК. Никто не увидел и начали на меня кукарекать. То ещё ГК, давайте объясняйте что здесь говно.

    superhackkiller1997, 11 Июля 2013

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

    +126

    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    
    int main(){
    
    setbuf(stdout,NULL); //disable output buffering
    
    char *str=malloc(8);
    strcpy(str,"abcdefgh");
    
    str=realloc(str,strlen(str)+8);
    strcat(str,"efghefgh");     //sprintf(str,"%s%s",str,"efghefgh");
    
    int imax=1024/strlen(str)*1024*4;
    
    printf("%s","exec.tm.sec\tstr.length\n"); //fflush(stdout);
    
    time_t starttime=time(NULL);
    char *gstr=malloc(0);
    int i=0;
    char *pos;
    int lngth;
    
    char *pos_c=gstr;
    int str_len=strlen(str);
    
        while(i++ < imax+1000){
            lngth=strlen(str)*i;
            gstr=realloc(gstr,lngth+str_len);
            strcat(gstr,str);    //sprintf(gstr,"%s%s",gstr,str);
            pos_c+=str_len;
    
            pos=gstr;
            while(pos=strstr(pos,"efgh")){
                memcpy(pos,"____",4);
            }
    
            if(lngth % (1024*256)==0){
                printf("%dsec\t\t%dkb\n",time(NULL)-starttime,lngth/1024); //fflush(stdout);
            }
        }
    //printf("%s\n",gstr);
    
    }

    http://raid6.com.au/~onlyjob/posts/arena/ - банальый пример бенчмарков всяких недоЯП. Это новый топ10 шедевр на этот месяц.

    Именно про такие бенчи кукарекают питушки, когда ссылаются на какие-то бенчи - самое смешно в этом то, что %подставить имя ЯП% сравнивать с сишкой бесполезно, ибо их стдлиб написана на Си и дрёглает либц. Т.е. сравнивая стдлиб разных ЯП - вы сравниваете сишные реализации и оверхеды самих ЯП.

    superhackkiller1997, 11 Июля 2013

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var bl = ['Stertor'];
    $('li.hentry').each(function(){
        var elem = $(this),
            against = elem.find('p.vote > a.vote-against'),
            who = elem.find('p.author a:nth-child(2)').text();
        if(bl.indexOf(who) != -1) {
            if(against.length) against.click();
            elem.hide();
        }
    });

    "не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;"
    Like this?

    russling, 11 Июля 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Byte[] content = setting.RecipientType == ReportRecipientType.A?
                            Processor.Process(Encoding.ASCII.GetBytes(report.Value),"A",String.Empty) :
                            setting.RecipientType == ReportRecipientType.B || setting.RecipientType == ReportRecipientType.BX?
                            Processor.Process (Encoding.ASCII.GetBytes(report.Value), "B", String.Empty) :
                             setting.RecipientType == ReportRecipientType.C?
                             Processor.Process (Encoding.UTF8.GetBytes(report.Value), "C", String.Empty) :
                             setting.RecipientType == ReportRecipientType.D?
                             Processor.Process (Encoding.UTF8.GetBytes(report.Value), "D", String.Empty) :
                            Processor.Process (Encoding.UTF8.GetBytes(report.Value), filename, DateTime.Now, setting.data);

    Имена переменных и методов обфусцированы, но суть не в них.
    Какой сумрачный гений родил такую управляющую структуру?

    startrack, 11 Июля 2013

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

    +74

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Дорогой участник! Не спеши покидать страницу. Я прошу тебя помочь:
    не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;
    минусуя других участников ты воспитываешь в себе чувство меры и помогаешь обществу снижать ЧСВ. 
    Заранее спасибо, друг мой. Ты будешь вознагражден за это деяние!
    
    Тот, кто покинул страницу, но не выполнил моей просьбы, умрет через 9 дней.

    Дорогой участник! Не спеши покидать страницу. Я прошу тебя помочь:
    не поленись, пройдись по всем постам, и поставь каждому участнику по минусу;
    минусуя других участников ты воспитываешь в себе чувство меры и помогаешь обществу снижать ЧСВ.
    Заранее спасибо, друг мой. Ты будешь вознагражден за это деяние!


    Тот, кто покинул страницу, но не выполнил моей просьбы, умрет через 9 дней.

    Stertor, 11 Июля 2013

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