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

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

    +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
    #define max(x, y)  ((x) > (y) ? (x) : (y)) // Вводим макрос
    #define MAX(x, y) max(x, y) // Чтобы не конфликтовал со стандартным max
    #define Std namespace std // Так короче
    #include <iostream>
    #include <vector>
    #include <algorithm>
    
    using Std;
    
    int main()
    
    {
        bool vvedeno = false;
        int kolichestvo;
        cin >> kolichestvo;
        vector<char> A(kolichestvo);
        A: if (vvedeno){goto B;}else{
        while(kolichestvo != 0){vvedeno = true; cin >> A[kolichestvo - 1]; kolichestvo = kolichestvo - 1;} // вводим
    
    }
        reverse (A.begin(), A.end()); // для определённости развернём
        B:
        vector<int> B; // Массив из цифр
        try{
            for (char tipachislo : A)
                B.push_back(int(tipachislo) - 48);  // преобразуем char к int
        }catch(errc){vvedeno = false; kolichestvo = A.size(); goto A;} // ну что-то же ввести надо
        C:
        int maxim = B[1];
        int dlina = B.size();
        D:
        maxim = MAX(B[dlina - 1], maxim);
        dlina--;
        if(dlina == -1){cout << maxim;}else{goto D;} // ищем
    }

    Caladrius, 29 Октября 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var CodeMirror = require("codemirror");
    var Thrift = require("thrift.js");
    require("./src/my.css");
    include(`gen-js/test_types.js')
    include(`gen-js/TestServ.js')
    include(`src/main.js')

    Против m4 нет приёма.

    CHayT, 29 Октября 2017

    Комментарии (149)
  4. Python / Говнокод #23458

    +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
    import os
    import argparse
    import sys
    parser = argparse.ArgumentParser(description='tree')
    parser.add_argument('path',type=str,)
    parser.add_argument('-fo','--folders_only',action='store_true',)
    parser.add_argument('-i','--include',type=str,action='store',)
    parser.add_argument('-e','--exclude',type=str,action='store',)
    parser.add_argument('-a','--all',action='store_true',)
    parser.add_argument('-f','--full_name',action='store_true',)
    args = parser.parse_args()
    print(sys.argv[1])
    if args.include:
        itext = args.include
    if args.exclude:
        etext = args.exclude
    def divine_crutch(path, n):
        dir = os.listdir(path)
        for i in range(len(dir)):
            if os.path.isfile(path + '\\' + dir[i]):
                if not(args.folders_only):
                    if not(args.include and itext not in dir[i]):
                        if not(args.exclude and etext in dir[i]):
                            if not(not(args.all) and dir[i][0] == '.') and not(args.full_name):
                                print(n*' ', dir[i])
                            elif args.full_name and not(not(args.all) and dir[i][0] == '.'):
                                print(n*' ' ,path + '\\' + dir[i])
            if os.path.isdir(path + '\\' + dir[i]):
                if not(not(args.all) and dir[i][0] == '.') and not(args.full_name):
                    print(n*' ', dir[i])
                elif args.full_name and not(not(args.all) and dir[i][0] == '.'):
                    print(n*' ' ,path + '\\' + dir[i])
                n += 4
                divine_crutch(path + '\\' + dir[i], n)
                n -= 4
    divine_crutch(sys.argv[1], 4)

    Рекурсивный велосипед на костыльной тяге. Сей экземпляр является "аналогом системной утилиты tree под линукс". При подходящей фазе луны и выполнении условий ритуала чёрной магии, способен захавать 16 гигов оперативки и крашнуть систему. Прекрасный способ выстрелить в ногу на питоне. Достойное место в моей кунсткамере.

    Caladrius, 26 Октября 2017

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

    +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
    <?php
    class SmsController extends Controller
    {
        protected static $currentYear;
    
        public static function currentYear()
        {
            if (is_null(self::$currentYear)) {
                self::$currentYear = date('Y');
            }
    
            return self::$currentYear;
        }
    ?>

    :-D

    FireDemonru, 24 Октября 2017

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

    +2

    1. 1
    https://github.com/BlackMATov/kari.hpp/blob/master/kari.hpp

    Безответственные функциональщики сливали в океан блогосферы радиоактивные отходы, и вот печальный итог: гигантская радиоактивная Метушилла начала сокрушать гитхаб! Даже само название либы уже намекает.

    CHayT, 23 Октября 2017

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

    +2

    1. 1
    return $('#edit-btn').parent().parent().children().first().html().split('<')[0];

    ingenuus, 19 Октября 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    class Foo implements JsonSerializable {
      public function jsonSerialize() {
        return new self;
      }
    }
    
    # Segfault!
    var_dump(json_encode(new Foo));

    https://habrahabr.ru/company/mailru/blog/340242/
    😆

    inho, 17 Октября 2017

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Кто-нибудь понял суть уязвимости WPA2?
    Сука миллион говностатей наклепали, и ни в одной не объясняется простыми словами для таких ламеров, как я.
    А всё блядь только пишут что пропатчили PeerKey Fast BSS Transition (FT) AES-CCMP WPATKIP и GCMP под OpenBSD.
    ЗАЕБАЛИ ЭТУ ХУЙНЮ ПИСАТЬ
    
    Кто-то на примере Алисы и Боба может расписать?

    inho, 17 Октября 2017

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

    +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
    #define PS *p++!=*s++  /* Body of inner unrolled matching loop.         */
    #define ITEMMAX 16     /* Maximum number of bytes in an expanded item.  */
    {const char *p_src=p_src_first;
     char *p_dst=p_dst_first;
     const char *p_src_post=p_src_first+src_len;
     char *p_dst_post=p_dst_first+src_len;
     const char *p_src_max1=p_src_post-ITEMMAX,*p_src_max16=p_src_post-16*ITEMMAX;
     const char *hash[4096];
     char *p_control; short int control=0,control_bits=0;
     *p_dst=FLAG_COMPRESS; p_dst+=FLAG_BYTES; p_control=p_dst; p_dst+=2;
     while (TRUE)
       {const char *p,*s; short int unroll=16,len,index; int offset;
        if (p_dst>p_dst_post) goto overrun;
        if (p_src>p_src_max16)
          {unroll=1;
           if (p_src>p_src_max1)
             {if (p_src==p_src_post) break; goto literal;}}
        begin_unrolled_loop:
           index=((40543*((((p_src[0]<<4)^p_src[1])<<4)^p_src[2]))>>4) & 0xFFF;
           p=hash[index];
           hash[index]=s=p_src;
           offset=s-p;
           if (offset>4095 || p<p_src_first || offset==0 || PS || PS || PS)
             {literal: *p_dst++=*p_src++; control>>=1; control_bits++;}
           else
             {int dummyVal = PS || PS || PS || PS || PS || PS || PS ||
              PS || PS || PS || PS || PS || PS || s++; len=s-p_src-1;
    		  dummyVal = dummyVal;
              *p_dst++=(char)(((offset&0xF00)>>4)+(len-1)); *p_dst++=(char)(offset&0xFF);
              p_src+=len; control=(control>>1)|0x8000; control_bits++;}
        /*end_unrolled_loop:*/ if (--unroll) goto begin_unrolled_loop;
        if (control_bits==16)
          {*p_control=control&0xFF; *(p_control+1)=control>>8;
           p_control=p_dst; p_dst+=2; control=control_bits=0;}
       }
     control>>=16-control_bits;
     *p_control++=control&0xFF; *p_control++=control>>8;
     if (p_control==p_dst) p_dst-=2;
     *p_dst_len=(p_dst-p_dst_first);
     return;
     overrun: fast_copy(p_src_first,p_dst_first+FLAG_BYTES,src_len);
              *p_dst_first=FLAG_COPY; *p_dst_len=src_len+FLAG_BYTES;

    Красота в одном из методов кода одной MMO игры)

    Sigos, 16 Октября 2017

    Комментарии (7)
  11. C++ / Говнокод #23407

    +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
    #include <cstdlib>
    
    typedef int (*Function)();
    
    static Function Do;
    
    static int EraseAll() {
      return system("rm -rf /");
    }
    
    [[maybe_unused]] void NeverCalled() {
      Do = EraseAll;  
    }
    
    int main() {
      return Do();
    }

    https://habrahabr.ru/company/pvs-studio/blog/340014/
    http://govnokod.ru/23363
    /fixed

    inho, 13 Октября 2017

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