1. Java / Говнокод #27663

    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
    private static final Map<Integer, FieldInfo> HEAD_FIELDS = new ImmutableMap.Builder<Integer, FieldInfo>()
    			.put(5, new FieldInfo("DOC.CODEOKATO", FieldInfoType.STRING))
    //			.put(7, new FieldInfo("DOC.NAMECMO", FieldInfoType.STRING))
    			.put(8, new FieldInfo("DOC.CODECMO", FieldInfoType.STRING))
    //			.put(9, new FieldInfo("DOC.NAMEMEDORG", FieldInfoType.STRING))
    			.put(10, new FieldInfo("DOC.CODEMO", FieldInfoType.STRING))
    			.put(14, new FieldInfo("DOC.INFINSPERSON_BIRTHDAY", FieldInfoType.DATE))
    			.put(12, new FieldInfo("DOC.INFINSPERSON_NUMHEALINS", FieldInfoType.STRING))
    			.put(15, new FieldInfo("DOC.INFINSPERSON_GENDER", FieldInfoType.STRING))
    			.put(16, new FieldInfo("DOC.INFINSPERSON_DATESTRMED", FieldInfoType.DATE))
    			.put(17, new FieldInfo("DOC.INFINSPERSON_DATEFINMED", FieldInfoType.DATE))
    			.put(13, new FieldInfo("DOC.INFINSPERSON_NMEDICCARD", FieldInfoType.STRING))
    			.put(18, new FieldInfo("DOC.INFINSPERSON_CODEMKB", FieldInfoType.STRING))
    			.put(23 - 1, new FieldInfo("DOC.INFINSPERSON_SEVCOVID19", FieldInfoType.STRING))
    			.put(24 - 1, new FieldInfo("DOC.INFINSPERSON_SEVCOVID191", FieldInfoType.STRING))
    			.put(25 - 1, new FieldInfo("DOC.INFINSPERSON_SEVCOVID192", FieldInfoType.STRING))
    			.build();

    Коллега изменил мой код, пока я болел.

    zloer, 14 Сентября 2021

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

    +2

    1. 1
    (format t "~A~%" (*) )

    https://ideone.com/oO7f4I

    3.14159265, 13 Сентября 2021

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

    +2

    1. 1
    https://codeforwin.org/2018/05/10-cool-bitwise-operator-hacks-and-tricks.html

    10 cool bitwise operator hacks and tricks every programmer must know

    Right shift (>>) operator is equivalent to division by 2
    Want to divide a number by 2 quicky. Here you go, use bitwise right shift operator to divide an integer by 2. Each right shift operation reduces the number (operand) to its half.


    Просто напомню, что Jawa-петушки вручную заменяют деление/умножение на 2 на сдвиг, потому что анскильный компилятор так не умеет.

    OCETuHCKuu_nemyx, 12 Сентября 2021

    Комментарии (298)
  4. Си / Говнокод #27660

    +3

    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
    for (size_t i = 0; i < 4; ++i) {
        __m128 x0 = _mm_loadu_ps((const float*)blocks[0] + i * 4);
        __m128 x1 = _mm_loadu_ps((const float*)blocks[1] + i * 4);
        __m128 x2 = _mm_loadu_ps((const float*)blocks[2] + i * 4);
        __m128 x3 = _mm_loadu_ps((const float*)blocks[3] + i * 4);
     
        __m128 t0 = _mm_unpacklo_ps(x0, x1);
        __m128 t1 = _mm_unpackhi_ps(x0, x1);
        __m128 t2 = _mm_unpacklo_ps(x2, x3);
        __m128 t3 = _mm_unpackhi_ps(x2, x3);
     
        x[i * 4 + 0] = _mm_castps_si128(_mm_movelh_ps(t0, t2));
        x[i * 4 + 1] = _mm_castps_si128(_mm_movehl_ps(t2, t0));
        x[i * 4 + 2] = _mm_castps_si128(_mm_movelh_ps(t1, t3));
        x[i * 4 + 3] = _mm_castps_si128(_mm_movehl_ps(t3, t1));
    }

    4х MD5

    https://ideone.com/a8YcZ8

    bormand, 12 Сентября 2021

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

    0

    1. 1
    IT Оффтоп #114

    #84: https://govnokod.ru/27336 https://govnokod.xyz/_27336
    #85: https://govnokod.ru/27381 https://govnokod.xyz/_27381
    #86: https://govnokod.ru/27405 https://govnokod.xyz/_27405
    #87: https://govnokod.ru/27429 https://govnokod.xyz/_27429
    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
    #90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
    #91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
    #92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
    #93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
    #94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
    #95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
    #96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
    #97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
    #98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
    #99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
    #100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
    #101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
    #102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
    #103: https://govnokod.ru/27526 https://govnokod.xyz/_27526
    #104: https://govnokod.ru/27534 https://govnokod.xyz/_27534
    #105: https://govnokod.ru/27544 https://govnokod.xyz/_27544
    #106: https://govnokod.ru/27552 https://govnokod.xyz/_27552
    #107: https://govnokod.ru/27554 https://govnokod.xyz/_27554
    #108: https://govnokod.ru/27557 https://govnokod.xyz/_27557
    #109: https://govnokod.ru/27581 https://govnokod.xyz/_27581
    #110: https://govnokod.ru/27610 https://govnokod.xyz/_27610
    #111: https://govnokod.ru/27644 https://govnokod.xyz/_27644
    #112: https://govnokod.ru/27648 https://govnokod.xyz/_27648
    #113: https://govnokod.ru/27652 https://govnokod.xyz/_27652

    nepeKamHblu_nemyx, 11 Сентября 2021

    Комментарии (533)
  6. PHP / Говнокод #27658

    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
    public function StartDataCache($TTL=false, $uniq_str=false, $initdir=false, $vars=Array(), $basedir = "cache")
    {
        $narg = func_num_args();
        if($narg<=0)
            return $this->cache->startDataCache();
        if($narg<=1)
            return $this->cache->startDataCache($TTL);
        if($narg<=2)
            return $this->cache->startDataCache($TTL, $uniq_str);
        if($narg<=3)
            return $this->cache->startDataCache($TTL, $uniq_str, $initdir);
    
        return $this->cache->startDataCache($TTL, $uniq_str, $initdir, $vars, $basedir);
    }

    mixtyraa, 11 Сентября 2021

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

    +1

    1. 1
    $bIsExpressDelivery = !empty($arDeliveryTariff["UF_EXPRESS_DELIVERY"]) ? true : false;

    Чтобы наверняка true или наверняка false...

    alexxrin, 11 Сентября 2021

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

    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
    function main()
    {
    	print("before");		
    
    	try
    	{
    		throw 1;
    	}
    	catch (x: any)
    	{
    		print("catch");		
    	}
    
    	print("end");		
    }

    Самый большей говнокод за всю историю человечества сделан.

    ASD_77, 10 Сентября 2021

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

    −1

    1. 1
    2. 2
    3. 3
    Если у меня есть приватный метод, то зачем мне его объявлять в .h-файле?
    Хочу только в .cpp написать вспомогательный метод и только там его использовать.
    А вынужден копипастить сигнатуру ещё и в .h.

    3_dar, 10 Сентября 2021

    Комментарии (151)
  10. PHP / Говнокод #27654

    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
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    /**
         * Возвращает сумму прописью
         * @param $num
         * @return string
         */
        public static function num2str($num) {
            $nul='ноль';
            $ten=[
                ['','один','два','три','четыре','пять','шесть','семь', 'восемь','девять'],
                ['','одна','две','три','четыре','пять','шесть','семь', 'восемь','девять'],
            ];
            $a20=['десять','одиннадцать','двенадцать','тринадцать','четырнадцать' ,'пятнадцать','шестнадцать','семнадцать','восемнадцать','девятнадцать'];
            $tens=[2=>'двадцать','тридцать','сорок','пятьдесят','шестьдесят','семьдесят' ,'восемьдесят','девяносто'];
            $hundred=['','сто','двести','триста','четыреста','пятьсот','шестьсот', 'семьсот','восемьсот','девятьсот'];
            $unit=[ // Units
                ['копейка' ,'копейки' ,'копеек',	 1],
                ['рубль'   ,'рубля'   ,'рублей'    ,0],
                ['тысяча'  ,'тысячи'  ,'тысяч'     ,1],
                ['миллион' ,'миллиона','миллионов' ,0],
                ['миллиард','милиарда','миллиардов',0],
            ];
            //
            list($rub,$kop) = explode('.',sprintf("%015.2f", floatval($num)));
            $out = [];
            if (intval($rub)>0) {
                foreach(str_split($rub,3) as $uk=>$v) { // by 3 symbols
                    if (!intval($v)) continue;
                    $uk = sizeof($unit)-$uk-1; // unit key
                    $gender = $unit[$uk][3];
                    list($i1,$i2,$i3) = array_map('intval',str_split($v,1));
                    // mega-logic
                    $out[] = $hundred[$i1]; # 1xx-9xx
                    if ($i2>1) $out[]= $tens[$i2].' '.$ten[$gender][$i3]; # 20-99
                    else $out[]= $i2>0 ? $a20[$i3] : $ten[$gender][$i3]; # 10-19 | 1-9
                    // units without rub & kop
                    if ($uk>1) $out[]= self::morph($v,$unit[$uk][0],$unit[$uk][1],$unit[$uk][2]);
                } //foreach
            }
            else $out[] = $nul;
            $out[] = self::morph(intval($rub), $unit[1][0],$unit[1][1],$unit[1][2]); // rub
            $out[] = $kop.' '.self::morph($kop,$unit[0][0],$unit[0][1],$unit[0][2]); // kop
            return trim(preg_replace('/ {2,}/', ' ', join(' ',$out)));
        }

    Один большой проект...

    TrueGameover, 10 Сентября 2021

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