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

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

    +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
    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
    // https://jaycarlson.net/2019/09/06/whats-up-with-these-3-cent-microcontrollers/
    // The C code I used for those original MCU tests looked something like this:
    
    volatile int16_t in[25];
    volatile int16_t out[25];
    const int16_t a0 = 16384;
    const int16_t a1 = -32768;
    const int16_t a2 = 16384;
    const int16_t b1 = -25576;
    const int16_t b2 = 10508;
    int16_t z1, z2;
    int16_t outTemp;
    int16_t inTemp;
    void main()
    {
      while(1) {
        _pa = 2;
        for(i=0;i<25;i++)
        {
          inTemp = in[i];
          outTemp = inTemp * a0 + z1;
          z1 = inTemp * a1 + z2 - b1 * outTemp;
          z2 = inTemp * a2 - b2 * outTemp;
          out[i] = outTemp;
        }
        _pa = 0;
      }
    }
    
    // The Padauk code looks like this:
    
    WORD in[11];
    WORD out[11];
    WORD z1, z2;
    WORD pOut, pIn; // these are pointers, but aren't typed as such
    int i;
    void  FPPA0 (void)
    {
      .ADJUST_IC  SYSCLK=IHRC/2    //  SYSCLK=IHRC/2
      PAC.6 = 1; // make PA6 an output
      while(1) {
        PA.6 = 1;
        pOut = out;
        pIn = in;
        i = 0;
        do {
          *pOut = (*pIn << 14) + z1;
          z1 = -(*pIn << 15) + z2
            + (*pOut << 14)
            + (*pOut << 13)
            + (*pOut << 9)
            + (*pOut << 8)
            + (*pOut << 7)
            + (*pOut << 6)
            + (*pOut << 5)
            + (*pOut << 3);
          z2 = (*pIn << 14)
            - (*pOut << 13)
            - (*pOut << 11)
            - (*pOut << 8)
            - (*pOut << 3)
            - (*pOut << 2);
          i++;
          pOut++;
          pIn++;
        } while(i < 11);
        PA.6 = 0;
      }
    }

    > As for the filter function itself, you’ll see that all the multiplies have been replaced with shift-adds. The Padauk part does not recognize the * operator for multiplication; trying to use it to multiply two variables together results in a syntax error. No, I’m not joking.

    j123123, 11 Октября 2019

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

    +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
    <?php
    
    function split_hash($hash, $sizes) {
        $cnt = count($sizes);                   // количество словарей
        $partSize = floor(128/4/$cnt);          // размер части хэша в тетрадах
        $result = array();
        foreach($sizes as $size) {
            $tmp = substr($hash, 0, $partSize); // разбиваем хэш по тетрадам на равные части
            $hash = substr($hash, $partSize);   
            $result[] = gmp_intval(gmp_mod(gmp_init($tmp, 16), $size)); // возвращаем остаток от деления фрагмента хэша 
                                                                        // на размер словаря
        }
        return $result;
    }
    
    function R($hash, $dicts) {
        $sizes = array_map(function($val){return count($val);}, $dicts); // получаем размеры каждого словаря
        $indices = split_hash($hash, $sizes);
        $result = '';
        foreach($indices as $dictNumber=>$index) {
            $result .= $dicts[$dictNumber][$index]; // сцепляем слово из частей
        }
        return $result;
    }
    
    function make_chain($start, $length, $dicts) {
        for($i = 0; $i < $length; ++$i) {
            $hash = md5($start);
            echo $hash . ' : ' . $start . PHP_EOL;
            $start = R($hash, $dicts);
        }
    }
    
    make_chain('свинособака', 10, array(
          array('свино',  'овце', 'тигро', 'косатко', 'зубро', 'волко', 'кото'),
          array('собака', 'бык',  'лев',   'дельфин', 'бизон')
    ));

    Выводит:

    360629d3cf05cee0240a23e1251c58a0 : свинособака
    1f7ad860b089c0e1141de02ac1e6e3ef : волкобизон
    6f2e4e3025c9dd840f1fa4a78792ef31 : котобизон
    d5812761186013ecca674a2704d5a081 : зубробык
    b4499d259156939bb74cbc1743632c8d : овцебизон
    c28ad194fcc581f538d109f8acb6b1f5 : волкобык
    663a3e06c88185db8fd4f81829e66b85 : котодельфин
    30bb70e972bf073c7aa4ec93c8d5b9a0 : косаткодельфин
    cc31cd8554c1add0128013bba2e47317 : волколев
    d88e78b7340637370628848b1957b4c2 : котособака


    http://ideone.com/rxqpj1

    ropuJIJIa, 10 Октября 2019

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

    +1

    1. 1
    Хочу, чтобы  3.14159265, 1024--, vistefan, kegdan, bormand вернулись в новогоднюю ночь.

    OCETuHCKuu_nemyx, 09 Октября 2019

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Число 1 = 1;
    Число номер 2 = 2;
    Сумма = Число 1 + Число номер 2;
    print Сумма; print; 
    function Открытие двери в поезде() {
      print "Дверь открыта"; print;
    }
    Открытие двери в поезде();

    https://habr.com/ru/sandbox/133385/

    OCETuHCKuu_nemyx, 06 Октября 2019

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

    +1

    1. 1
    2. 2
    3. 3
    size_t 	nChLen = it_ch_end - it_ch;
    
    до меня дошло не сразу.

    OlegUP, 03 Октября 2019

    Комментарии (18)
  7. Pascal / Говнокод #25892

    +1

    1. 1
    https://pastebin.com/8c6KxabR

    Бон аппетит, блядь.

    cmepmop, 01 Октября 2019

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

    +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
    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
    <?php
    $fin = fopen($argv[1], 'r');
    if($fin === false) die();
    
    $fout = fopen('dump.csv', 'w');
    if($fout === false) die();
    
    while(!feof($fin)) {
        $rawline = fgets($fin);
        if(!preg_match('#\[+(.*)\]+,?#', $rawline, $matches)) continue;
        $fields = str_getcsv($matches[1]);
        $parts = explode(')', $fields[0]);
        if(count($parts) < 2) continue;
        list($host, $path) = $parts;
        $domains = explode(',', $host);
        $dirs    = explode('/', $path);
        if($domains[0] === 'ru' && $domains[1] === 'mail') {
            $email = $dirs[2] . '@' . $dirs[1] . '.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        } else if($domains[0] === 'ru' && $domains[1] === 'rambler' && $dirs[1] = 'users') {
            if(strpos($dirs[2], '@') === false) {
                $email = $dirs[2] . '@rambler.ru';
            } else {
                $email = $dirs[2];
            }
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        } else if($domains[0] === 'ru' && $domains[1] === 'ya') {
            $email = $domains[2] . '@yandex.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.by';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.ua';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.kz';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@yandex.com';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $domains[2] . '@ya.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        } else if($domains[0] === 'ru' && $domains[1] === 'yandex' && $dirs[1] = 'users') {
            $email = $dirs[2] . '@yandex.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.by';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.ua';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.kz';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@yandex.com';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
            $email = $dirs[2] . '@ya.ru';
            $hash = md5($email);
            fputcsv($fout, array($hash, $email));
        }
    }
    
    fclose($fout);
    fclose($fin);

    Генератор радужных таблиц для е-мейлов.

    Особенность программы в том, что «JSON» парсится как «CSV» в целях экономии оперативки.

    ropuJIJIa, 01 Октября 2019

    Комментарии (34)
  9. Java / Говнокод #25882

    +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
    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
    public class Main {
        public static void main(String[] args) {
            ThreeD[] f = {new ThreeD(5, 9, 7), new FourD(1,3,8,5)};
            Coords<ThreeD> c = new Coords<>(f);
            showXYZ(c);
            FiveD[] x = new FiveD[] {new FiveD(11,22,3,4, 123)};
            Coords<FiveD> b = new Coords<>(x);
            showAll(b);
            FiveD[] z = new FiveD[] {new FiveD(1,2,1,6,5)};
            Coords<FiveD> zz = new Coords<>(z);
        }
        private static void showXY(Coords<? super FourD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" ");
            }
        }
    
        private static void showXYZ(Coords<? extends ThreeD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" ");
            }
        }
        private static void showAll(Coords<? extends FiveD> c) {
            for(int i = 0; i < c.coords.length; i++) {
                System.out.println(c.coords[i].x +" "+ c.coords[i].y+" "+c.coords[i].z+" "+c.coords[i].t+" "+c.coords[i].m);
            }
        }
    }
    
    class Coords<T extends TwoD> {
        T[] coords;
        Coords(T[] o) {
            coords = o;
        }
    }
    
    class TwoD {
        int x,y;
        TwoD(int a, int b) {
            x = a;
            y = b;
        }
    }
    class ThreeD extends TwoD {
        int z;
        ThreeD(int a, int b, int c) {
            super(a, b);
            z = c;
        }
    }
    class FourD extends ThreeD {
        int t;
        FourD(int a, int b, int c, int d) {
            super(a, b, c);
            t = d;
        }
    }
    class FiveD extends FourD {
        int m;
        FiveD(int a, int b, int c, int d, int e) {
            super(a, b, c, d);
            m = e;
        }
    }

    говнецо или нет

    codershitter, 29 Сентября 2019

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

    +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
    //Создадим типизированные колонки в ТЗ
    	Запрос = Новый Запрос("ВЫБРАТЬ
    	                      |	CRM_ЗначенияРеквизитовТрафика.РеквизитТрафика КАК РеквизитТрафика,
    	                      |	CRM_ЗначенияРеквизитовТрафика.ЗначениеРеквизита КАК ЗначениеРеквизита,
    	                      |	CRM_ЗначенияРеквизитовТрафика.ИдентификаторТрафика
    	                      |ИЗ
    	                      |	РегистрСведений.CRM_ЗначенияРеквизитовТрафика КАК CRM_ЗначенияРеквизитовТрафика
    	                      |ГДЕ
    	                      |	CRM_ЗначенияРеквизитовТрафика.ИдентификаторТрафика ЕСТЬ NULL");
    	РеквизитыТрафика = Запрос.Выполнить().Выгрузить();
    	//Удалим "лишние записи" на всякий случай
    	РеквизитыТрафика.Очистить();
    	
    	//Заполним реквизиты трафика
    	
    	//Логин клиента из онлайнконсультанта
    	НовоеСвойство = РеквизитыТрафика.Добавить();
    	НовоеСвойство.ИдентификаторТрафика = Идентификатор;
    	НовоеСвойство.РеквизитТрафика = ПланыВидовХарактеристик.CRM_РеквизитыТрафика.ОнлайнКонсультантЛогинКлиента;
    	НовоеСвойство.ЗначениеРеквизита = Описание.ЛогинКлиента;
    
    	//Запись в регистр
    	НЗ = РегистрыСведений.CRM_ЗначенияРеквизитовТрафика.СоздатьНаборЗаписей();
    	НЗ.Отбор.ИдентификаторТрафика.Установить(Идентификатор);
    	НЗ.Прочитать();
    	НЗ.Загрузить(РеквизитыТрафика);
    	Нз.Записать();

    Зачем столько раз читать регистр не понятно. Для чего вообще нужна типизированная таблица если используется прочитать? Одни вопросы.

    NioGoth, 27 Сентября 2019

    Комментарии (8)
  11. JavaScript / Говнокод #25873

    +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
    /**
       * The expanded S-box and inverse S-box tables.  These will be computed
       * on the client so that we don't have to send them down the wire.
       *
       * There are two tables, _tables[0] is for encryption and
       * _tables[1] is for decryption.
       *
       * The first 4 sub-tables are the expanded S-box with MixColumns.  The
       * last (_tables[01][4]) is the S-box itself.
       *
       * @private
       */
      _tables: [[[],[],[],[],[]],[[],[],[],[],[]]],

    booratihno, 26 Сентября 2019

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