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

    В номинации:
    За время:
  2. 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)
  3. Куча / Говнокод #27334

    +1

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

    OCETuHCKuu_nemyx, 01 Апреля 2021

    Комментарии (35)
  4. 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)
  5. 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)
  6. 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)
  7. Куча / Говнокод #-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)
  8. C++ / Говнокод #27317

    +1

    1. 1
    pubimbue, ate и ios

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

    booratihno, 25 Марта 2021

    Комментарии (235)
  9. Куча / Говнокод #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)
  10. Куча / Говнокод #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)
  11. C++ / Говнокод #27312

    +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
    #include <iostream>
    
    template<typename T>
    struct CrtpBase {
        static float base_func()
        {
            std::cout << "CrtpBase::base_func(), " << typeid(T).name() << "::int_field == "
                << T::int_field << std::endl;
            return 16.0f;
        }
    
        static inline float x = base_func();
    };
    
    struct A: public CrtpBase<A> {
        void func_a()
        {
            base_func();
        }
    
        static inline int int_field = 16;
    };
    
    struct B : public CrtpBase<B> {
        void func_b()
        {
            std::cout << "B::func_b(), no CrtpBase<B>::base_func() call" << std::endl;
        }
    };
    
    
    int main()
    {
        A a;
        a.func_a();
    
        B b;
        b.func_b();
    }

    [temp.inst]/2:
    Unless a class template specialization is a declared specialization,
    the class template specialization is implicitly instantiated when
    the specialization is referenced in a context that requires a
    completely-defined object type or when the completeness of the
    class type affects the semantics of the program.

    [temp.inst]/3:
    The implicit instantiation of a class template specialization causes
    (3.1) -- the implicit instantiation of the declarations, but not of the definitions, of
    the non-deleted class member functions, member classes, scoped member enumerations,
    static data members, member templates, and friends; and
    (3.2) -- the implicit instantiation of the definitions of deleted member functions,
    unscoped member enumerations, and member anonymous unions.

    [temp.inst]/4:
    Unless a member of a templated class is a declared specialization, the specialization
    of the member is implicitly instantiated when the specialization is referenced in a
    context that requires the member definition to exist or if the existence of the definition
    of the member affects the semantics of the program; in particular, the initialization
    (and any associated side effects) of a static data member does not occur unless the
    static data member is itself used in a way that requires the definition of the static
    data member to exist.


    Таким образом, по стандарту CrtpBase<B>::x не должен быть инициализирован, поскольку он нигде не used in a way that requires the definition of the static data member to exist. Правильные компиляторы (gcc и clang) это понимают и компилируют код, а вот Visual Studio зачем-то пытается инициализировать CrtpBase<B>::x и нон-конформно ломается.

    PolinaAksenova, 24 Марта 2021

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