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

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

    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
    $snippet = preg_split('/'. $qs .'/i', $replace);
            $c = 1;
            foreach( $snippet as $snip ) {
              $length  = strlen( $snip ) * .3;
              $xlength = strlen( explode( $qs, $snip )[0] ); 
              if( $c % 2 !== 0 ) {
                $highlight_1 = substr( $snip, $xlength * .3, $xlength );
              }
              else {
                $highlight_2 = substr( $snip, 0, $length );
              }
              $c++;
            }
            $output .= '<dfn class="revolver__search-snippet">... '. preg_replace("#[^а-яА-ЯA-Za-z:;._,? -]+#u", '', $highlight_1) . '<mark>'. $qs .'</mark>'. preg_replace("#[^а-яА-ЯA-Za-z:.;_,? -]+#u", '', $highlight_2) .' ...</dfn></li>';

    Pick — самая маленькая поисковая система на PHP и MySQL
    Здесь пришлось повозиться. Простой подход совсем не подразумевал, что PHP начнет обрабатывать UTF-8 корректно, но я смог добиться работы с русским и английским языками.

    https://habr.com/post/526652

    gost, 08 Ноября 2020

    Комментарии (13)
  3. C++ / Говнокод #26911

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int main()
    {
        + ! - ! -- -- ! + ! - - - ++ ~ - ! -- -- -- ~ ~ ~ ++ ++ ++ - ~ ++ - * - - -
        * ++ * * ++ * -- -- -- -- - * -- + * ++ ++ ++ ++ ++ * ++ * -- -- * -- - *
        
        BRAINFUCK;
        
        return 0;
    }

    https://ideone.com/EtK1J4

    Ответ на https://govnokod.ru/26910. Теперь с реальной конпеляцией в нативный код.

    bormand, 03 Сентября 2020

    Комментарии (13)
  4. PHP / Говнокод #26886

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private function changePlans(Coupon $coupon): Coupon
    {
            $coupon->paypal_plan_yearly_rub_id = $this->getPaypalId($coupon->billingPlanYearlyRub, $coupon);
            $coupon->paypal_plan_yearly_usd_id = $this->getPaypalId($coupon->billingPlanYearlyUsd, $coupon);
            $coupon->paypal_plan_monthly_rub_id = $this->getPaypalId($coupon->billingPlanMonthlyRub, $coupon);
            $coupon->paypal_plan_monthly_usd_id = $this->getPaypalId($coupon->billingPlanMonthlyUsd, $coupon);
    
            return $coupon;
    }

    Вот это забавно $this->getPaypalId($coupon->billingPlanMonthlyUsd, $coupon); (getPaypalId приватный)

    hrustbb2, 20 Августа 2020

    Комментарии (13)
  5. Python / Говнокод #26721

    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
    apibrėžti WSGIHandler(aplin, pradžia_atsakymas):
        globalinis prašymas
        globalinis atsakymas
        prašymas.įpareigoti(aplin)
        atsakymas.įpareigoti()
        bandyti:
            prižiūrėtojas, argi = rungtynės_url(prašymas.kelias, prašymas.metodas)
            jei not prižiūrėtojas:
                kelti HTTPKlaida(404, "Nerastas")
            produkcija = prižiūrėtojas(**argi)
        išskyrus BreakButelio kaip antsparnis:
            produkcija = antsparnis.produkcija
        išskyrus Exception kaip išimtis:
            atsakymas.statusas = getattr(išimtis, 'http_statusas', 500)
            klaidaprižiūrėtojas = KLAIDA_HANDLER.get(atsakymas.statusas, klaida_nutylėjimą)
            bandyti:
                produkcija = klaidaprižiūrėtojas(išimtis)
            išskyrus:
                produkcija = "Išimtis per klaidos prižiūrėtojas! Prašymas sustabdyti."
    
            jei atsakymas.statusas == 500:
                prašymas._aplin['wsgi.errors'].write("Error (500) on '%s': %s\n" % (prašymas.kelias, išimtis))
    
        db.uždaryti()
        jei turiatrib(produkcija, 'read'):
            failąišvesties = produkcija
            jei 'wsgi.file_wrapper' iš aplin:
                produkcija = aplin['wsgi.file_wrapper'](failąišvesties)
            kitas:
                produkcija = iter(lambda: failąišvesties.read(8192), '')
        kijei isinstance(produkcija, stg):
            produkcija = [produkcija.encode()]
    
        dėl c iš atsakymas.SLAPUKAI.values():
            atsakymas.antraštė.papildyti('Set-Cookie', c.OutputString())
        statusas = '%d %s' % (atsakymas.statusas, HTTP_KODAI[atsakymas.statusas])
        pradžia_atsakymas(statusas, sąrašas(atsakymas.antraštė.daiktai()))
        sugrįžti produkcija

    Отсюда:
    https://github.com/Setonas/setonas

    TEH3OPHblu_nemyx, 01 Июня 2020

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

    −3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Что это за бесячая стрелка на говнокоде, которая появляется при горизонтальном скроле?
    https://i.imgur.com/uRcKSDO.png
    
    Браузер - Opera. В FF, IE, Google Chrome - не воспроизводится. 
    Это заговр против Норвежских разработчиков?

    Her, 29 Января 2020

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    h1{color: #b60000; font-size: <?php if( $dop_for_evm==1 ){echo '3.5vw;';} else {echo '30px;';}?> line-height: 1.1;padding-right: 5%; padding-left: 5%; text-align: center;}
    h2{font-size:<?php if( $dop_for_evm==1 ){echo '2.8vw;';} else {echo '30px;';}?>padding-right: 5%; padding-left: 5%; text-align: center;}
    .h2{font-size: <?php if( $dop_for_evm==1 ){echo '2.2vw;';} else {echo '28px;';}?>padding-right: 5%; padding-left: 5%; text-align: center;}
    h3{font-size: <?php if( $dop_for_evm==1 ){echo '2.6vw;';} else {echo '29px;';}?>padding-right: 5%; padding-left: 5%; text-align: center;}
    h4{font-size: <?php if( $dop_for_evm==1 ){echo '2.6vw;';} else {echo '29px;';}?>padding-right: 5%; padding-left: 5%; text-align: center;}
    h5{font-size: <?php if( $dop_for_evm==1 ){echo '2.6vw;';} else {echo '29px;';}?>padding-right: 5%; padding-left: 5%; text-align: center;}
    h6{font-size: <?php if( $dop_for_evm==1 ){echo '2.6vw;';} else {echo '29px;';}?>padding-right: 5%; padding-left: 5%; text-align: center;}

    zooks, 30 Ноября 2019

    Комментарии (13)
  8. Куча / Говнокод #26039

    0

    1. 1
    do { code = randomCode(); } while (code.contains("FUCK"));

    Пользователь с ником «Чапаев» опубликовал скриншот рекламного SMS-сообщения от
    сбербанка, содержащего код «CRYVKILLJEWS», что можно перевести с английского
    как «плачь, убивай евреев».

    Интересно, а как генерируют все эти случайные коды? Там ведь много чего вылезти может... Например, мне от банка приходят 4-хзначные коды, но я не помню, чтобы пришли, скажем, 4 одинаковые цифры. Не знаю, случайность ли это или алгоритм такой.

    (проверочный код: 8bog)

    Steve_Brown, 22 Ноября 2019

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

    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
    public class HttpQueryNameValueCollection : NameValueCollection
        {
            private ParallelLoopResult _parallelLoopResult;
    
            public override string ToString()
            {
                List<string> result;
                result = new List<string>();
                _parallelLoopResult = Parallel.ForEach(AllKeys, p =>
                {
                    if (BaseGet(p) != null)
                        result.Add(p + "=" + Get(p));
                });
                return string.Join("&", result);
            }
        }

    Формирование ссылки с query-параметрами недостаточно быстро, поэтому нужно это сделать в параллель :D

    adoconnection, 24 Октября 2019

    Комментарии (13)
  10. Lua / Говнокод #25829

    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
    if self.Weapon:GetNextPrimaryFire() < CurTime() then
    	if GetConVarNumber( "ma2_togglechargeui" ) == 1 then
    		if (self.Charge-self.DmgMin)/self.DmgMax*100<=10 then
    			ply:SetNWString("chargebar","██")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=20 then
    			ply:SetNWString("chargebar","████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=30 then
    			ply:SetNWString("chargebar","██████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=40 then
    			ply:SetNWString("chargebar","████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=50 then
    			ply:SetNWString("chargebar","██████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=60 then
    			ply:SetNWString("chargebar","████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=70 then
    			ply:SetNWString("chargebar","██████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=80 then
    			ply:SetNWString("chargebar","████████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=90 then
    			ply:SetNWString("chargebar","██████████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100>90 then
    			ply:SetNWString("chargebar","████████████████████")
    			ply:SetNWBool("chargemaxxxed",true)
    		end
    	end
    end

    https://steamcommunity.com/sharedfiles/filedetails/?id=1825542758

    amd, 11 Сентября 2019

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

    0

    1. 1
    2. 2
    3. 3
    We could replace the nonce with a deterministic value, but it's not entirely clear what the cryptographic implications are. At the very least, it allows attackers to obverse that a secret has changed, or that it has changed back to a previously observed value.
    
    https://github.com/edolstra/rfcs/blob/nix-encryption/rfcs/0005-nix-encryption.md

    Продолжаем наблюдения

    CHayT, 04 Июня 2019

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