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

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

    +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
    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
    int
    next_day( int mmdd )
    {
       struct tm time;
       time_t clock;
       int date;
       int secs_in_day = 60 * 60 * 24;
    
       /* convert date to mmdd if in yyyymmdd format */
       if (mmdd > 9999)
          mmdd = mmdd % 10000;
    
       /* Get today's date/time in seconds since 1970 */
       clock = time( NULL );
    
       /* Loop until we obtain a clock time corresponding to the day passed in */
       while ( 1 )
       {
          /* Get structure with filled in date/time info. for day corresponding to
           * the clock value we're currently working on & construct date from that.
           */
          localtime( &clock, &time );
          date =  (tm->tm_mon + 1) * 100 + tm->tm_mday;
          if ( date > mmdd )
          {
             /* Set clock back to previous day */
             clock -= secs_in_day;
             continue;
          }
    
          /* Set clock forward to next day */
          clock += secs_in_day;
          if ( date < mmdd )     /* Date is in future */
             continue;
    
          tm = localtime( &clock );
          date =  (tm->tm_mon + 1) * 100 + tm->tm_mday;
          return date;     /* Next date after one passed in */
       }
    }

    Функция, получает день в виде числа в формате mmdd, возвращает следующий день в текущем году в таком же формате.

    vovochka, 13 Октября 2017

    Комментарии (0)
  3. Ruby / Говнокод #23398

    +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
    def with_batched_ids(count, ids)
      if ids.is_a? Array
        if ids.length > 1
          ids.each_slice(count) do |ids|
            yield(ids)
          end
        else
          yield(ids)
        end
      else
        yield(ids)
      end
    end

    Заshitное программирование и просто красивая портянка из yield - end - else. Как на ровном месте придумать целый метод.

    strax, 10 Октября 2017

    Комментарии (1)
  4. Assembler / Говнокод #23394

    +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
    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
    tms     код DSP   пример MMACF32
    
          msubf32      MR1,MR1,MR2        ;
       || mmov32  @point14,mr0            ;
          mmov32  @point15,mr1            ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmov32       mr2,@point01         ;     01
          msubf32      mr2,mr2,mr1          ;     01-15
       || mmov32       mr1,@_cos2           ;           B
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmpyf32      mr2,mr2,mr1          ;mr2=(01-15)B
       || mmov32       mr1,@point02         ;     02
          msubf32      mr0,mr1,mr0          ;mr0=(02-14)
       || mmov32       mr1,@_cos4           ;           C
          mmov32       mr3,@point00         ;     00
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmacf32      mr3,mr2,mr2,mr1,mr0  ;mr3=00+(01-15)B mr2=(02-14)C
       || mmov32       mr0,@point03         ;
          mmov32       mr1,@point13         ;
          msubf32      mr0,mr0,mr1          ;
       || mmov32       mr1,@_cos6           ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmacf32      mr3,mr2,mr2,mr1,mr0  ;mr3=00+(01-15)B+(02-14)C mr2=(03-13)D
       || mmov32       mr0,@point05         ;
          mmov32       mr1,@point11         ;
          msubf32      mr0,mr0,mr1          ;
       || mmov32       mr1,@_cos10          ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ...............

    maxxx, 09 Октября 2017

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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    #include <iostream>
    #include <algorithm>
    
    using namespace std;
    
    int main() {
        std::string s = "";
        std::getline(std::cin, s);
        int max = 0;
        long max_n = 0;
        string curr = "";
        s += ' ';
        for(char& c : s) {
            if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
                curr += c;
            else {
                max_n = std::atoi(curr.c_str());
                if (max_n >= max) {
                    max = max_n;
                }
                curr.erase(curr.begin(), curr.end());
            }
        }
        cout << max << endl;
        return 0;
    }

    Ну что, парень, костыльнём?

    Caladrius, 09 Октября 2017

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Make Sean moan
    Worship Carrie's feet
    
    Bind Amy to Saint Andrew's Cross
        Have Amy hogtie Sean
        If Amy is Carrie's bitch
            Make Slave scream Sean's name
            Make Sean moan

    https://github.com/Property404/fetlang

    dxd, 07 Октября 2017

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function xhr(method, url, async, user, password) {
        let r = new XMLHttpRequest();
        r.open(method, url, async, user, password);
        r.timeout = 10;
    }

    Аффтар данной конструкции задаёт типа загадку:
    "Есть у нас обертка над XMLHttpRequest. Отгадайте что может пойти не так?"

    Ссыль: https://pikabu.ru/story/zagadka_po_js_5383775

    ps. Учи стандарты JS фокусник!

    Dg_INC, 04 Октября 2017

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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    #include <iostream>
    #include <restinho/all.hpp>
    
    int main()
    {
      restinho::http_server_t<> http_server{
        restinho::create_child_io_context(1),
        [](auto & settings) {
          settings.port(8080).address("localhost")
            .request_handler([](auto req) {
              req->create_response().set_body("answer").done();
              return restinho::request_accepted();
            });
        }};
    
      http_server.open();
      std::cin.ignore();
      http_server.close();
    
      return 0;
    }

    https://habrahabr.ru/company/yandex/blog/336264/#comment_10444326

    C++ начинает напоминать какой-то нодежс.

    inho, 29 Сентября 2017

    Комментарии (31)
  9. Ruby / Говнокод #23360

    +1

    1. 1
    https://github.com/ruby/ruby/blob/trunk/parse.y

    Как распарсить Руби код.

    wvxvw, 25 Сентября 2017

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    (* /*
    C > /) 2> /dev/null & echo hello world!; exit
    *       This file is correct input for:
    *       sh, cc, pc, f77
    */ main(program)) { puts("hello world!"); /*
    *) program main(output);begin writeln('hello world!')end. {
          write( *, '("hello world!")')
          end
    */ return &program; }

    Bash: https://ideone.com/HKy5RJ
    C: https://ideone.com/KFbJsK
    Pascal (fpc): https://ideone.com/4zcc51

    inkanus-gray, 12 Сентября 2017

    Комментарии (42)
  11. Куча / Говнокод #23344

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    (*a/*/ % #)(PostScript)/Helvetica 40 selectfont 9 400 moveto show%v"f"a0
    true showpage quit%#) 2>/dev/null;echo bash;exit #*/);int main()/*>"eb"v
    %a*0)unless print"perl\n"__END__*/{printf("C\n");/*>>#;"egnu">:#,_@;,,,<
    *)begin writeln(*\output={\setbox0=\box255}\eject\shipout\hbox{\TeX}\end
    *)('pascal');end.{*/return 0;}

    C: https://ideone.com/Ntu3S0
    Pascal (fpc): https://ideone.com/A9qZ0x
    Bash: https://ideone.com/TYr7cu
    Perl: https://ideone.com/fAUhiv

    inkanus-gray, 12 Сентября 2017

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