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

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

    +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
    void printParser(const wchar_t *fileName, const wchar_t *str, boolean showLineCharPos)
    {
        ts::Parser parser;
        auto sourceFile = parser.parseSourceFile(fileName, str, ScriptTarget::Latest);
    
        ts::FuncT<> visitNode;
        ts::ArrayFuncT<> visitArray;
    
        auto intent = 0;
    
        visitNode = [&](ts::Node child) -> ts::Node {
    
            for (auto i = 0; i < intent; i++)
            {
                std::cout << "\t";
            }
    
            std::cout << "Node: " << wtoc(parser.syntaxKindString(child).c_str()) << " @ [ " << child->pos << " - " << child->_end << " ]" << std::endl;
    
            intent++;
            ts::forEachChild(child, visitNode, visitArray);    
            intent--;
    
            return undefined;
        };
    
        visitArray = [&](ts::NodeArray<ts::Node> array) -> ts::Node {
            for (auto node : array)
            {
                visitNode(node);
            }
    
            return undefined;
        };
    
        auto result = ts::forEachChild(sourceFile.as<ts::Node>(), visitNode, visitArray);
    }

    спортировал TypeScript парсер в C++ и ахренел от обьема работы :)

    ASD_77, 06 Апреля 2021

    Комментарии (188)
  3. Python / Говнокод #27339

    +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
    def ForQueryInAddr(query, addr):
    	global listed, primalsource
    	print("Searcing in: "+addr)
    	html = requests.get(addr,proxies=proxies).text
    	if (query.lower() in html.lower()):
    		print("==============================================")
    		print("Query found in: "+addr)
    		print("==============================================")
    	if ("<html>" in html or "<head>" in html):
    		data = PyQuery(html)
    		links = data('a')
    		for link in links:
    			ahref = link.attrib['href']
    			#print("Found: "+ahref)
    			if (ahref not in listed):
    				if (ahref[0].lower() == "h"):
    					if (primalsource in ahref):
    						if (ahref[-3:].lower() not in filetypes and ahref[-4:].lower() not in filetypes and ahref[-5:].lower() not in filetypes):
    							listed.append(ahref)
    							ForQueryInAddr(query, ahref)

    https://github.com/Dev1lroot/OnionSearch/blob/master/main.py

    PolinaAksenova, 06 Апреля 2021

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

    +1

    1. 1
    С днём математика вас, питухи!

    OCETuHCKuu_nemyx, 01 Апреля 2021

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

    +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
    // если пользователь авторизован
    if($user->get('id')) { 
        $_SESSION['city-select'] = '';
        // если пользователь авторизован - определяем город
        $profile = $user->getOne('Profile');
        if ($profile) {
            $city = $profile->get('city');
        }
        
        // проходим все города и ищем подходящий
        $cities = $modx->runSnippet('pdoResources', array(
            'parents' => 205,
            'limit'   => 0,
            'includeTVs' => 'setCityForHome',
            'where'   => '{ "template" : "25" }',
            'tpl'     => '@CODE:{"id":"[[+id]]","city":"[[+tv.setCityForHome]]"}',
            'outputSeparator' => ','
        ));
        $redirectTo = 0;
        if($cities) { 
            $cities = $modx->fromJson('['.$cities.']');
            foreach( $cities as $c ) {
                if($c['city'] == $city) {
                    $redirectTo = $c['id'];
                    break;
                }
            }    
        }
    } else {
        // если не авторизован - проверяем сессию
        
        $session = $_SESSION['city-select'];
        
        // если сессия пустая - проверяем, на какой странице находимся
        // если страница города и пустая сессия - записываем в сессию
        if($modx->resource->get('template') == 25) {
            $_SESSION['city-select'] = $modx->resource->get('pagetitle');
            $city = $modx->resource->get('pagetitle');
        } else {
            $city = (!empty($_SESSION['city-select']))? $_SESSION['city-select'] : $city;
        }
    }

    Сумрачный гений, сука. Строки 11-28 особенно примечательны.

    CatScratchFever, 31 Марта 2021

    Комментарии (10)
  6. Pascal / Говнокод #27324

    +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
    program square;
    
    var sep, input: string;
      i, j, n, m : integer;
      
    
    begin
      write('sep:');
      readln(sep);
      
      write('str:');
      readln(input);
      
      for i:=1 to length(input) do write(input[i], ' ');
      writeln();
      for i:=2 to length(input)-1 do begin
        write(input[i]);
        for j:=1 to length(input)*2-3 do write (sep);
        writeln(input[length(input) - i + 1]);
      end;
      for i:=0 to length(input)-1 do 
        write(input[length(input)-i], ' ');
    end.

    Написала на скучной лекции программку на телефоне, чтобы распечатывать

    Х У Й
    У У
    Й У Х


    и прочие интересности UwU

    Пользуйтесь на здоровье, лицензия GNU GPL V3!

    KoWe4Ka_l7porpaMMep, 28 Марта 2021

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

    +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
    $query = "
    	SELECT
    		`version`, `mods`, `plugins`, `keywords`
    	WHERE
    		`version` = {$version}";
    foreach (explode(",", $mods) as $mod)
    {
    	$query += "AND `mods` LIKE '{$mod}' OR `mods` LIKE '{$mod},%' OR `mods` LIKE '%,{$mod},%' OR `mods` LIKE '%,{$mod}'";
    }
    foreach (explode(",", $plugins) as $plugin)
    {
    	$query += "AND `plugins` LIKE '{$plugin}' OR `plugins` LIKE '{$plugin},%' OR `plugins` LIKE '%,{$plugin},%' OR `plugins` LIKE '%,{$plugin}'";
    }

    Говнокод чтобы прогнать массив с id записей внутри varchar по массиву с id записей из переменной (id,id,id)

    Dev1lroot, 27 Марта 2021

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

    +1

    1. 1
    Просто оффтоп #17

    #1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
    #2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
    #3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
    #4: (vanished) https://govnokod.xyz/_25472
    #5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
    #6: (vanished) https://govnokod.xyz/_26649
    #7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
    #8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
    #9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
    #10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
    #11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
    #12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
    #13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
    #14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
    #15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
    #16: https://govnokod.ru/27282 https://govnokod.xyz/_27282

    nepeKamHblu_nemyx, 26 Марта 2021

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

    +1

    1. 1
    pubimbue, ate и ios

    давайте ржать над крестостримами

    booratihno, 25 Марта 2021

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

    +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
    ?check_trace(
           begin
               %% Inject some orderings to make sure the replicant
               %% receives transactions in all states.
               %%
               %% 1. Commit some transactions before the replicant start:
               ?force_ordering(#{?snk_kind := trans_gen_counter_update, value := 5}, #{?snk_kind := state_change, to := disconnected}),
               %% 2. Make sure the rest of transactions are produced after the agent starts:
               ?force_ordering(#{?snk_kind := subscribe_realtime_stream}, #{?snk_kind := trans_gen_counter_update, value := 10}),
               %% 3. Make sure transactions are sent during TLOG replay:
               ?force_ordering(#{?snk_kind := state_change, to := bootstrap}, #{?snk_kind := trans_gen_counter_update, value := 15}),
               %% 4. Make sure some transactions are produced while in normal mode
               ?force_ordering(#{?snk_kind := state_change, to := normal}, #{?snk_kind := trans_gen_counter_update, value := 25}),
    ...

    Какой тест )))

    CHayT, 24 Марта 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    # PowerShell
    
    switch ($true)
    {
        ($firstNumber -gt $secondNumber) {Write-Output ("{0} > {1}" -F $firstNumber, $secondNumber)}
        ($firstNumber -eq $secondNumber) {Write-Output ("{0} == {1}" -F $firstNumber, $secondNumber)}
        ($firstNumber -lt $secondNumber) {Write-Output ("{0} < {1}" -F $firstNumber, $secondNumber)}
    }

    Интересный такой свитч-кейс (https://stackoverflow.com/questions/57063932/powershell-overriding-assignment-and-comparison-operators)

    groser, 24 Марта 2021

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