1. Assembler / Говнокод #17539

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    add ax,1 ; Добавляем в ax 1 (не знаю, почему он так сделал, МЕДЛЕННО И 3 БАЙТА), можно было же inc ax
    add ax,1
    add ax,1
    add ax,1
    add ax,1
    add ax,1
    add ax,1
    add ax,1
    add ax,1
    mov ax,9 ; А теперь я понял тщетность бытия и те потраченные байты выше.

    Самый лучший говнокод новичка, который я видел.

    Mihip, 28 Января 2015

    Комментарии (10)
  2. Assembler / Говнокод #17538

    +198

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    org 100h ; DOS, чёрной пеленой покрытый DOS...
    
    delGovnocode:
    mov eax,govnokod ; Помещаем в EAX говнокод
    xor eax,eax ; Обнуляем EAX
    
    govnokod db "AllGovnocodeInTheWorld" ; говнокод

    Самый эффективный способ уничтожения говнокода, который является говнокодом.

    Mihip, 28 Января 2015

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int n;
        cin >> n;
        int nums[n];
        for (int i = 0; i < n; i++)
            nums[i] = pow(i + 1, 2);

    Немного эзотерики.
    nums[4] = 24

    DesmondHume, 28 Января 2015

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

    +160

    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
    'idate' => 
            array (
              'UNIX' => '1346688000',
              'datetime' => '03.09.2012 19:00',
              'time' => '19:00',
              'hour' => '19',
              'second' => '00',
              'date' => '03.09.2012',
              'datename' => '03 September 2012',
              'year' => '2012',
              'y' => '12',
              'd' => '03',
              'd0' => '3',
              'm' => '09',
              'm0' => '9',
              'month' => 'September',
              'day' => 'Monday',
              'monthr' => 'сентября',
              'datenamer' => '03 сентября 2012',
              'ago' => '2 года назад',
            ),

    Правильное хранение даты. Работаю недавно и сам рак еще тот - но это слишком. Переношу БД из в свой проект и встречаю это...

    VladDelec, 28 Января 2015

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

    +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
    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
    // Common styles for any tag
    .clear {
      clear: both;
    }
    
    .grey {
      color: $pcolor;
    }
    
    .colored {
      color: $headercolor;
    }
    
    .siteName {
      font-family: $siteNameFontFamily;
    }
    
    .common-ctx {
      color: $pcolor;
      font-size: 105%;
    }
    .common-ctx-light {
      color: $pcolorlight;
      font-size: 100%;
    }
    
    .fs95 {
      font-size: 95%;
    }
    
    .undisplayable {
      display: none;
    }
    
    .displayable {
      display: block;
    }
    
    hr.black-hr {
        border-color: black;
        margin: 10px 0 10px 0;
    }
    
    hr.grey-hr {
        border-color: #cccccc;
        margin: 20px 0 30px 0;
    }
    
    .w30p {
      width: 30% !important;
    }
    
    .w100 {
      width: 100%;
    }
    
    .fl {
      float: left;
    }
    
    .p0 {
        padding: 0 !important;
    }

    Самые интуитивно-понятные имена CSS-классов.

    crazyh, 28 Января 2015

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

    +134

    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
    void MSSequencerPatternCopyToMusicTrack(MSSequencerPatternRef self, MusicTrack track)
    {
        // Get signature and length of pattern
        TimeSignature sign   = MSSequencerPatternGetTimeSignature(self);
        CABarBeatTime length = pattern_barbeat_duration_without_mutes(self);
        CABarBeatTime insert = CABarBeatTime(1, 1);
        // Get muted beats
        CFRange *mutedBeats = (CFRange*)CFDataGetBytePtr(self->mutedBeats);
        CFIndex  mutedCount = CFDataGetLength(self->mutedBeats) / sizeof(CFRange);
        // Copy with muted regions
        if (mutedCount > 0)
        {
            // Clear output track
            MSSequencerTrackClear(self->parent, track);
            // Copy phrase by phrase
            for (int i = 0; i < mutedCount; ++i)
            {
                CFRange muteRange  = mutedBeats[i];
                CFIndex beatsCount = (sign.numerator * sign.denominator);
                
                if ((beatsCount * (i + 1)) > muteRange.location + muteRange.length)
                {
                    if (muteRange.length > 0)
                    {
                        // Copy beats before mute range
                        if (muteRange.location > (beatsCount * i))
                        {
                            CFIndex start = (beatsCount * i);
                            CFIndex end   = muteRange.location;
                            insert = copy_beats_to_track_from_beat_to_beat(self, track, sign, insert, start, end);
                        }
                        // Copy beats after range
                        {
                            CFIndex start = (muteRange.location + muteRange.length);
                            CFIndex end   = (beatsCount * (i + 1));
                            insert = copy_beats_to_track_from_beat_to_beat(self, track, sign, insert, start, end);
                        }
                    }
                    else
                    {
                        // Copy without mutes
                        CFIndex start = (beatsCount * i);
                        CFIndex end   = (beatsCount * (i + 1));
                        insert = copy_beats_to_track_from_beat_to_beat(self, track, sign, insert, start, end);
                    }
                }
                else
                {
                    // Copy beats
                    CFIndex firstBeat = (muteRange.location + muteRange.length) % beatsCount;
                    CABarBeatTime start = CABarBeatTimeAddBeats(CABarBeatTime(1, 1), sign, (beatsCount * i) + firstBeat);
                    CABarBeatTime end   = CABarBeatTimeAddBeats(start, sign, (beatsCount - muteRange.length));
                    copy_beats_from_pattern_to_track(self, track, start, end, insert);
                    //CFLog("start: {%i, %i}, end: {%i, %i}, insert: {%i, %i}", (int)start.bar, (int)start.beat, (int)end.bar, (int)end.beat, (int)insert.bar, (int)insert.beat);
                    // Update insert time
                    insert = CABarBeatTimeAddBeats(insert, sign, (beatsCount - muteRange.length));
                }
            }
        }
        // Copy without muted regions
        else
        {
            copy_beats_from_pattern_to_track(self, track, insert, length, insert);
        }
        //CAShow(track);
    }

    Вот такая вот какашечка...

    gerasim13, 28 Января 2015

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

    −388

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    - (void) setLevel:(NSInteger)level {
        if (level > (long)[_ranksDictionary count] - 1) level = (long)[_ranksDictionary count] - 1;
        if (level < 0) level = 0;
    
        _level = level;
        
        self.currentRank = [_ranksDictionary objectForKey:[NSNumber numberWithInteger:_level]];
        
        if (rankDataItem.integerValue != -_level)
            rankDataItem.integerValue = _level;
    }

    Я совсем хуевый?

    ExT, 28 Января 2015

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
    {
        double bytesIn = double.Parse(e.BytesReceived.ToString());
        double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
        double percentage = bytesIn / totalBytes * 100;
        label2.Text = "Downloaded " + e.BytesReceived + " of " + e.TotalBytesToReceive;
        progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
    }

    Вычилсяем проценты :D

    Xekep, 28 Января 2015

    Комментарии (0)
  9. Python / Говнокод #17531

    −113

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    def convert_get_to_post(header='HTTP_X_GET_DATA'):
        def decorator(function):
            @wraps(function)
            def wrapper(request, *args, **kwargs):
                if header in request.META:
                    request.method = 'GET'
                    request.GET = request.POST
                return function(request, *args, **kwargs)
            return wrapper
        return decorator

    Как избежать проблему с большим количеством параметров в URL при GET запросе...

    winter, 27 Января 2015

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

    +51

    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
    static bool convertCharToHexByte(char& ch)
    {
    	if (ch >= '0' && ch <= '9') {
    		ch -= '0';
    		return true;
    	}
    
    	if (ch >= 'a' && ch <= 'f') {
    		ch -= 'a';
    		ch += 0xA;
    		return true;
    	}
    
    	if (ch >= 'A' && ch <= 'F') {
    		ch -= 'A';
    		ch += 0xA;
    		return true;
    	}
    
    	return false;
    }

    alek0585, 27 Января 2015

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