1. Си / Говнокод #24447

    0

    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
    void check_manifest_line (int p) {
      static char c[MAX_LINE_LEN + 1];
      int l = p - START_MANIFEST_POSITION;
      if (l <= MAX_LINE_LEN && l > 4) {
        get_binlog_data (c, START_MANIFEST_POSITION, l);
        c[l] = 0;
        char *pp = c;
        int op = -1;
        if (l >= 6 && !memcmp (c, "start", 5)) {
          op = 1; 
          pp += 5;
        } else if (l >= 5 && !memcmp (c, "stop", 4)) {
          op = 2;
          pp += 4;
        } else if (l >= 8 && !memcmp (c, "version", 7)) {
          op = 3;
          pp += 7;
        }
        if (is_whitespace (*pp) && op > 0) {      
          pp ++;
          pp = eat_whitespace (pp);
          if (!*pp) {
            START_MANIFEST_POSITION = p + 1;
            return;
          }
          if (op == 1 || op == 2) {
            char *rr = pp;
            pp = eat_not_whitespace (pp);
            char *zz = pp;
            pp = eat_whitespace (pp);
            *zz = 0;
            if (pp == c + l && zz - rr > 0) {
              struct cluster *C = CC;
              int x = BINLOG_NAME_LEN - 1;
              while (x >= 0 && BINLOG_NAME[x] != '/') {
                x--;
              }
              add_cluster (BINLOG_NAME, x + 1, rr, (MAIN_REPLICA ? 2 : 0) + (op == 2 ? 4 : 0) + (1 << 30));
              CC = C;
            }
          } else {
            assert (op == 3);
            char *rr = pp;
            pp = eat_not_whitespace (pp);
            char *rr_end = pp;
            pp = eat_whitespace (pp);
            *rr_end = 0;
            if (!*pp) {
              START_MANIFEST_POSITION = p + 1;
              return;
            }
            int version = atoi (pp);
            pp = eat_not_whitespace (pp);
            pp = eat_whitespace (pp);
            if (!*pp) {
              START_MANIFEST_POSITION = p + 1;
              return;
            }
            long long size = atoll (pp);
            pp = eat_not_whitespace (pp);
            pp = eat_whitespace (pp);
            if (pp == c + l && rr_end > rr && version > 0 && size >= 0) {
              struct cluster *C = CC;
              int x = BINLOG_NAME_LEN - 1;
              while (x >= 0 && BINLOG_NAME[x] != '/') {
                x --;
              }
              int rrlen = rr_end - rr;
              int i;
              for (i = 0; i < max_cluster; i++) if (Clusters[i]) {
                //fprintf (stderr, "i = %d, binlog_name = %s, rr = %s, rrlen = %d\n", i, Clusters[i]->binlog_name, rr, rrlen);
                const char *s = Clusters[i]->binlog_name;
                int l = strlen (Clusters[i]->binlog_name) - 1;
                while (l >= 0 && s[l] != '/') { l --; }
                s = s + l + 1;
                if (!memcmp (s, rr, rrlen) && s[rrlen] == '.') {
                  int old = atoi (s + rrlen + 1);
                  if (old >= version) {
                    vkprintf (0, "New version %d, old %d. Skipping\n", version, old);
                    START_MANIFEST_POSITION = p + 1;
                    return;
                  }
                  if (unlink (Clusters[i]->binlog_name) < 0) {
                    fprintf (stderr, "Can not delete old file %s: %m\n", Clusters[i]->binlog_name);
                  }
                  delete_cluster (i);
                }
              }
              static char name[1024];
              memcpy (name, rr, rrlen);
              name[rrlen] = '.';
              sprintf (name + rrlen + 1, "%06d", version);
              add_cluster (BINLOG_NAME, x + 1, name, (MAIN_REPLICA ? 2 : 0) + (1 << 30));
              LAST_SIZE = size;
              CC = C;
            }
          }
        }
      }
      START_MANIFEST_POSITION = p + 1;

    https://github.com/vk-com/kphp-kdb/blob/ce6dead5b3345f4b38487cc9e45d55ced3dd7139/copyfast/copyfast-engine.c#L1081-L1181


    Очередная порция вконтактового говнокода.

    j123123, 05 Июля 2018

    Комментарии (4)
  2. Куча / Говнокод #24445

    −1

    1. 1
    2. 2
    3. 3
    Яндекс начал индексировать Google Документы с паролями
    
    https://habr.com/post/416219/

    А в чем, собственно, здесь вина "Яндекс"? То что пользователи-долбоёбы держат пароли в общедоступных документах?
    В таком случае я и без "Яндекс" могу получить к ним доступ.

    CrashTesteAnusov, 05 Июля 2018

    Комментарии (16)
  3. Куча / Говнокод #24444

    −1

    1. 1
    https://habr.com/company/jugru/blog/416161/

    Есть только одна причина не использовать "k8s" - это всё не нужный ХУЙ! И никого не ебёт ваш "k8s" под "FreeBSD".
    Въебите этому посту, пожалуйста, минус.

    CrashTesteAnusov, 05 Июля 2018

    Комментарии (0)
  4. JavaScript / Говнокод #24443

    −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
    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
    <!DOCTYPE HTML>
    <html>
    <head>
    </head>
    <body>
    <h3 > enter a capcha </h3>
    <canvas id = "capchaGen" width="40" height="20"> </canvas>
    <button id = "rst" onclick = "a()"> get</button>
    <br />
    <input type = "text" placeholder = "capcha" name = "capchaIn" class ="box" id="capchaIn"required>
    <button
        id ="end" onclick = "c()">
        ok
    </button>
    <script>
    
    
    
    
    var pass = ''; 
    var capha = document.getElementById("capchaGen");
    var cap = capha.getContext("2d");
    function a(){
    cap.clearRect(0, 0, 40, 20);
     cap.strokeText(gen_pass() ,5,15);
    
    }
    
    function c(){
      var val=document.getElementById("capchaIn").value;
    
    
    if(val ==pass){
      
        alert("accept") 
        ///////site////site/////сайт
        window.open("https://google.com","_self")
        }
        else{
    alert("invalid capcha")
    a();
    }
    }
    chr = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',0,1,2,3,4,5,6,7,8,9);
    
    function rnd(x,y,z) {
    var num;
    do {
    num = parseInt(Math.random()*z);
    if (num >= x && num <= y) break;
    } while (true);
    return(num);
    }
    
    function gen_pass() {
    pass ='';
    for (var i = 0; i < 5; i++) pass += chr[rnd(0,61,100)];
    return  pass;
    }
    
    a();
    
    </script>
    
    <style>
    canvas{
        border-style:solid;
        background-color:#c7a956 ;
        border-width:1px;
        border-color: rgba(0,0,0,0.5)
    }
    .box{
    color:red;
        width:80px;
    }
    h3{
        color:green;
    }
    </style>
    </body>

    Капча. Обсирайте как можете.

    Arduino, 05 Июля 2018

    Комментарии (7)
  5. Lua / Говнокод #24440

    +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
    13. 13
    14. 14
    c:\Program Files (x86)\Lua\5.1>lua.exe c:\temp\1.lua
    0.0012512588885159
    
    c:\Program Files (x86)\Lua\5.1>lua.exe c:\temp\1.lua
    0.0012512588885159
    
    c:\Program Files (x86)\Lua\5.1>lua.exe c:\temp\1.lua
    0.0012512588885159
    
    c:\Program Files (x86)\Lua\5.1>lua.exe c:\temp\1.lua
    0.0012512588885159
    
    c:\Program Files (x86)\Lua\5.1>type c:\temp\1.lua
    print(math.random() )

    Луа под виндой как-то отчаянно сосет хуй не умея настоящие random из Windows Crypto API.
    В результате вызов 150 раз программы дает один и тот же random. Его конечно можно math.randomseed(os.time()), но то так, бо time это даже не милисекунды а сеунды.

    Забавно что под никсами все зробит как треьба

    :1$ lua51 1.lua
    0.31260803123592
    :2$ lua51 1.lua
    0.13656691980388
    :3$ lua51 1.lua
    0.56430453367732


    думаю оно читает /dev/random

    Золотой хуй, что это такое? Или Сёма прав и прыщелуа не умеет в winapi?

    roskomgovno, 04 Июля 2018

    Комментарии (116)
  6. Куча / Говнокод #24439

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Int main(){
    Var x = 0;
    <script>
    color:red;
    >>> print('Hello world!')
    Hello world!
    Delay(256);
    /\каминтарый
    Срать(понос, 1кг,деревенский сортир);
    Cout<<говно.type<<";"<<site.govnokod.ru;

    Что выведет компилятор. Каким матом будет покрывать. Боюсь представить..

    Arduino, 04 Июля 2018

    Комментарии (4)
  7. Куча / Говнокод #24438

    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
    <!DOCTYPE html>
    <html>
        <head>
            <title>Why is he always talking about that damm movie?</title>
        </head>
        
    <img src="https://cdn.shopify.com/s/files/1/0064/7532/products/poster-war-games-1983-regular-2_1024x1024.jpg?v=1455775393" width="350" height="250">
    <br>
    <p>Wargames 1983</p>
    <br>
    <p>from: https://en.wikipedia.org/wiki/WarGames</p>
    <p>The film follows David Lightman, a young hacker who unwittingly accesses WOPR (War Operation Plan Response), a United States military supercomputer originally programmed to predict possible outcomes of nuclear war. Lightman gets WOPR to run a nuclear war simulation, believing it to be a computer game. The computer, now tied into the nuclear weapons control system and unable to tell the difference between simulation and reality, attempts to start World War III.
    </p>
    <img src="http://cdn3-www.comingsoon.net/assets/uploads/2015/10/wargames-1.jpg" width="350" height="200">
    <br>
    <p>The computer stages a massive Soviet first strike with hundreds of missiles, submarines, and bombers. Believing the attack to be genuine, NORAD prepares to retaliate. Falken (Inventor/Programmer) and David convince military officials to cancel the second strike and ride out the attack. WOPR tries to launch the missiles itself, however, using a brute-force attack to obtain the launch code. Without humans in the control centers as a safeguard, the computer will trigger a mass launch. All attempts to log in and order to cancel the countdown fail, and all weapons will launch if the computer is disabled.</p>
        
    <br>    
        <img src="http://oliversmith.cc/wp-content/uploads/2014/11/Screen-Shot-2014-11-26-at-14.17.30-e1417011526324-640x469.png" width="350" height="200">
    <p>Falken and David direct the computer to play tic-tac-toe against itself. This results in a long string of draws, forcing the computer to learn the concept of futility and no-win scenarios. WOPR obtains the missile code, but before launching, it cycles through all the nuclear war scenarios it has devised, finding they, too, all result in stalemates. Having discovered the concept of mutual assured destruction ("WINNER: NONE"), the computer tells Falken that it has concluded that nuclear war is "a strange game" in which "the only winning move is not to play." WOPR relinquishes control of NORAD and the missiles and offers to play "a nice game of chess."</p>
        
      </body>  
    </html>

    Ржунимагу. Этот говно код набрал 25 лайков а нормальный мой код калькулятора во вкладке рядом 0. Куда катится мир...

    Arduino, 02 Июля 2018

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    https://github.com/mikael-s-persson/templight
    Templight 2.0 - Template Instantiation Profiler and Debugger
    
    Templight is a Clang-based tool to profile the time and memory consumption of
    template instantiations and to perform interactive debugging sessions to gain
    introspection into the template instantiation process.

    Шаблонные метапрограммисты будут довольны.
    Осталось еще сделать такое же, но чтобы constexpr можно было профилировать и интерактивно дебажить

    j123123, 02 Июля 2018

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

    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
    // Функция считывания списка из файла
    	private: int readContactList( System::String^ path ) {
    		contact_list_->clear();
    		try {
    			System::IO::StreamReader^ reader = gcnew System::IO::StreamReader( path ); // Объект чтения из файла
    			try {
    				System::String^ line; // считываемая строка
    				array<String^>^ contact = gcnew array<String^>( 32 ); // считываемая строка будет разбиваться 
    				array<String^>^ separator = { " " }; // разделитель строки - пробел
    				list_node* node; // вершина списка
    
    				while( line = reader->ReadLine() ) { 
    					contact = line->Split( ' ' ); // разделяем строку по пробелам
    					if ( contact->Length != 3 ) // Должно быть три числа
    						return 4;
    					try {
    						node = new list_node(); // Заводим вершину и инициализируем ее поля
    						node->element_number_ = Int32::Parse( contact[ 0 ] );
    						node->circuit_number_ = Int32::Parse( contact[ 1 ] );
    						node->contact_number_ = Int32::Parse( contact[ 2 ] );
    
    						contact_list_->pushBack( node );
    					} catch (Exception^ e) { // В случае ошибки удаляем вершину из кучи и выходим
    						delete node;
    						return 4;
    					}
    				}
    			} catch ( Exception^ e ) {
    				return 2;
    			}
    		} catch ( Exception^ e ) {
    			return 1;
    		}
    		return 0;
    	}

    Больше try - catch.
    Поля структуры не инкапсулировал потому, что тот, кому нужна эта программа не знает про инкапсуляцию.
    Кстати, сделано по примеру с MSDN

    OlegUP, 02 Июля 2018

    Комментарии (154)
  10. Си / Говнокод #24434

    −1

    1. 1
    main(){int i=0;char*c = "(5((((`+((((f(H+(P7(d(([)(/(`G(X)7d+(.X+d)X+d(_(d.GXA`gg/d(dggI7(dgg`+(dg7^)(dgKE((dGD/((d/K)(((((((((0X)(((7F(<(XK/H7(d`)`)(.D(F(H(G(/(D`7X(HOg+6(`YgX;(fd7d7//d+7X[+GHKgdX7gg77fcggYKgfg/";while(i++<1122)printf(i%34?(c[i/6]-40&1<<i%6)?"XX":" ":"\n");}

    Ёбаные обфускаторы.

    codemonkey, 02 Июля 2018

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