1. C# / Говнокод #13920

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    bool exit = false;
    while (!exit)
    {
        if (Console.KeyAvailable)
        {
            ConsoleKeyInfo key = Console.ReadKey(true);
            exit = true;
        }
    }

    Православная замена Console.ReadKey();

    adoconnection, 09 Октября 2013

    Комментарии (53)
  2. Python / Говнокод #13919

    −101

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def Find(dir):
            def walk(a,b,files):
                t1=0
                for i in files:
                    t1+=1
                    if i[-4:]==".sis" or i[-4:]==".Sis" or i[-4:]==".SIs" or i[-4:]==".SIS" or i[-4:]==".SiS" or i[-4:]==".sIS" or i[-4:]==".siS" or i[-5:]==".sisx" or i[-5:]==".Sisx" or i[-5:]==".SIsx" or i[-5:]==".SISx" or i[-5:]==".SISX" or i[-5:]==".sISX" or i[-5:]==".siSX" or i[-5:]==".sisX" or i[-5:]==".SisX" or i[-5:]==".SIsX" or i[-5:]==".SiSX" :
                        list1.append(cn(i))
                        list2.append(cn("%s\%s"%(b,i)))

    Когда еще была жива симба, под нее был интерпретатор питона. Этот отрывок - творение некоего китайского товарища под PyS60.

    Pythoner, 09 Октября 2013

    Комментарии (59)
  3. Си / Говнокод #13918

    +128

    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
    #include "unpacker.h"
    
    Unpacker::Unpacker(char *name) {
        _splitString = new char*[16];
        _ctx = SDL_RWFromFile(name, "rb");
    }
    
    Unpacker::~Unpacker() {
        delete _splitString;
        SDL_RWclose(_ctx);
        SDL_FreeRW(_ctx);
    }
    
    Dir *Unpacker::getDir(char *path) {;
        int index = 1;
        char pth[256];
        char name[80];
        char *str = "";
        if (!path)
            return NULL;
        _split(path);
        SDL_RWseek(_ctx, 2, SEEK_SET);
        pth[0] = '/'; pth[1] = '\0';
        while (_splitString[index]) {    
            Uint16 count;
            Uint32 hash;
            str = _splitString[index];
            hash = _hash(str);
            count = SDL_ReadLE16(_ctx);
            for (int i=0; i<count; i++) {
                Uint32 h;
                Uint32 offset;
                h = SDL_ReadLE32(_ctx);
                offset = SDL_ReadLE32(_ctx);
                if (hash == h) {
                    Uint8 size;
                    Uint32 curPos = SDL_RWtell(_ctx);
                    SDL_RWseek(_ctx, offset, SEEK_SET);
                    SDL_RWread(_ctx, &size, 1, 1);
                    SDL_RWread(_ctx, name, size, 1);
                    name[size] = '\0';
                    if (!strcmp(str, name)) {
                        if (_splitString[index+1]) {
                             strcat(pth, str);
                             strcat(pth, "/");
                        }
                        break;
                    } else {
                        if (i == count-1)
                            return NULL;
                        SDL_RWseek(_ctx, curPos, SEEK_SET);
                    }
                }
            }
            index++;
        }
        Dir *dir = new Dir;
        strcpy(dir->name,  str);
        strcpy(dir->path, pth);
        dir->dirsCount = SDL_ReadLE16(_ctx);
        dir->dirsOffset = SDL_RWtell(_ctx);
        SDL_RWseek(_ctx, dir->dirsCount*8, SEEK_CUR);
        dir->filesCount = SDL_ReadLE16(_ctx);;
        dir->filesOffset = SDL_RWtell(_ctx);
        return dir;
    }
    
    File *Unpacker::getFile(char *path) {
        char pth[256];
        char nm[80];
        int index = 2;
        _split(path);
        if (!_splitString[1])
            return NULL;
        if (_splitString[2]) {
            strcpy(pth, "/");
            strcpy(pth, _splitString[1]);
            strcat(pth, "/");
        } else {
            Dir *dir = getDir("/");
            return getFile(dir, _splitString[1]);
        }
        while (1) {
            if (_splitString[index+1]) {;
                strcat(pth, _splitString[index]);
                strcat(pth, "/");
            } else {
                strcpy(nm, _splitString[index]);
                break;
            }
            index++;
        }

    Нашел у себя на диске - старое творенье, когда я был мал и глуп... Распаковщик архива на своего формата на основе zlib.

    Pythoner, 09 Октября 2013

    Комментарии (32)
  4. Java / Говнокод #13917

    +70

    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
    // there is class PlayerExt, which extends class Player...
    // min >= 0
    // max <= players.size()
    
        List<PlayerExt> players = playerManager.getPlayers(contestId);
        Player[] response = new Player[players.size()];
    
        for (int i = min; i < max; i++) {
            response[i] = players.get(i);
            if (!players.get(i).isQualified()) {
                response[i].setChipStack(BigDecimal.valueOf(-1));
            }
            response[i].setPosition(i + 1);
            response[i].setCustomerId(players.get(i).getCustomerId());
        }

    Для таких начальных условий, как обозначено в комментарии в начале кода, формируем список игроков.
    Особенно вдохновляет самая последняя инструкция в теле цикла.

    wissenstein, 09 Октября 2013

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

    +27

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function makehash($str,$salt='',$strength='08'){
    	if (!$salt):
    		  $salt = "";
    		  for ($i = 0; $i < 22; $i++) {
    		    $salt .= substr("./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", mt_rand(0, 63), 1);
    		  }
    	endif;
        return crypt($str, "$2a$".$strength."$".$salt);
    }

    no comments

    brainstorm, 09 Октября 2013

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

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    n = strlen(pName);
    name = new char[n + 1];
    memset(name, 0, n + 1);
    memcpy(name, pName, n);

    боянчик. std::string наверное религия не позволяет. а strdup() слишком С. oh wait...

    Dummy00001, 09 Октября 2013

    Комментарии (61)
  7. JavaScript / Говнокод #13913

    +163

    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
    AdlAdbPromptDialog.callIfPromptDialogNeverClosedBefore(function(){
      AdlAdbPromptDialog.callIfAdblockerInDafaultState(function(){
       AdlAdbPromptDialog.callIfAdblockerEverTurnedOff(function(){
        AdlAdbPromptDialog.callIfAdblockerConfigShown(function(){
         AdlAdbPromptDialog.callIfPromptDialogSaveClicked(function(){
          AdlAdbPromptDialog.callIfAdsPresent(function(){
           AdlAdbPromptDialog.callIfUsingAdlMoreThanXdays(3, function(){
            callback();
           });
          });
         });
        }, AdlAdbPromptDialog.promptDialog.AdblockerConfigShown);
       }, AdlAdbPromptDialog.promptDialog.AdblockerEverTurnedOff);
      }, AdlAdbPromptDialog.promptDialog.AdblockerInDafaultState);
     });

    mxvz, 09 Октября 2013

    Комментарии (33)
  8. PHP / Говнокод #13912

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    
    if ($user_id == 0 || $user_id == '0') {
        /*НИЧЕГО*/
    }

    1С Битрикс, этим всё сказано...

    P.S давненько ничего не постил...

    qbbr, 09 Октября 2013

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

    +135

    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
    private void Button2_Click(object sender, EventArgs e)
        {
          this.Label4.Text = new StreamReader("C:\\Program Files\\Microsoft Visual Studio 10.0\\VB\\VBProjects\\датаметр\\датаметр\\bin\\Release\\Key.txt").ReadLine();
          if (Operators.CompareString(this.Label4.Text, "vrc5rhhgyuuoxr45", false) == 0)
          {
            this.Button1.Visible = true;
            this.TextBox1.Visible = true;
            this.Label1.Visible = true;
            this.Label4.Visible = false;
            this.Button2.Visible = false;
            this.Label3.Visible = true;
            int num = (int) Interaction.MsgBox((object) "Ключ верный.\r\nНе сообщайте его никому !!\r\nИ не потеряйте.", MsgBoxStyle.OkOnly, (object) null);
          }
          else
            this.Label4.Text = "Ключ не верный !!\r\nПоменяйте его в файле \"Key\"";
        }

    Классное расположение файла. Причём в архиве лежит пустой файл Key.txt рядом с программой...
    Как надо было извратиться, чтобы в коде оказался не просто абсолютный путь, но и вот такой-вот с Program Files, ведь по умолчанию VS создаёт проекты в Моих документах

    http://www.cyberforum.ru/vb-net/thread971437.html

    Qwertiy, 08 Октября 2013

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

    +105

    1. 1
    <div class="стиль38" style="position:relative; background:#333333; height:10px;"></div>

    Работа фрилансЁра. И потом удивляются, что я их не люблю.

    Vasiliy, 08 Октября 2013

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