1. Python / Говнокод #25573

    +1

    1. 1
    RE_DIGIT = re.compile(r'\D+')

    str.isdigit()
    не?

    ifinik, 26 Апреля 2019

    Комментарии (977)
  2. Python / Говнокод #25572

    −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
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    book = open("Kniga_Lolita.txt", "r")
    intab = ""
    outtab = ""
    deltab = '"?.,![]«»:()123456789-;#%'
    trantab = str.maketrans(intab, outtab, deltab)
    st = book.read()
    final = st.translate(trantab)
    you = ''
    fok = 0
    stak = 0
    def dekod(kod):
        lkod = len(kod)
        llkod = lkod
        kody = ''
        i = 0
        if lkod % 3 != 0:
            print('Т.к. вы написали слово кол-во символов которого')
            print('Дешифратор не сможет понять, последнии символы будут стерты из кода')
            print('Впредь будте внимательны, из этого код может расшифроваться неправильно!')
            while llkod % 3 != 0:
                i += 1
                llkod -= 1
            kody += kod[0:lkod - i]
            print('Чистый код: ')
            print(kody)
            dekod2(kody)
        else:
            kody += kod
            dekod2(kody)
    def dekod2(kody):
        i = 0
        j = 0
        dek = []
        lkody = len(kody)
        while j != lkody:
            j += 3
            dek += [kody[i:j]]
            i += 3
        print('Код разделенный по буквам: ')
        print(dek)
        dekod3(dek)
        
    def dekod3(dek):
        x = 0
        for i in range(len(dek)):
            for x in permutations(dek[i]):
                #print (x)
                dekod4(x)
    def dekod4 (x):
        new  = open("prog.txt", "w")
        aa = new.write(final)
        new.close()
        new = open("prog.txt", "r")
        st1 = ''
        st2 = ''
        for num, line in enumerate(new):
            if num == int(x[0]):
                lis = line.split()
                for num1, line1 in enumerate(lis):
                    if num1 == int(x[1]):
                        ss = ''
                        ss = line1
                        try:
                            st2 += ss[int(x[2])]
                            bild(st2)
                        except IndexError:
                            return 0
    def bild(st2): #000105202 Пример шифра: Лес
        global you
        global fok
        if st2:
            if len(st2) == 1:
               you += st2
               fok += 1
        if fok == 13: #Это число 13 просто потому, Если сделать не под магическую цифру, то можно будет испольновать и для 4-х буквенных слов и т.д.
            blin(you)
    def blin(you):
        tt =[]
        i = 0
        j = 6
        c = len(you)
        while c > 0: 
            tt += [[you[i:j]]]
            i += 6
            j += 6
            c -= 6
        print('Возможно не работающая лабутень!')
        for y in range(len(tt)):
            print(tt[y])
    print ('За книгу-код взято произведение Владимирa Набоковa - Лолита')
    print ('Список операций')
    print ('1.Закодировать')
    print ('3.Показать текст книги-кода')
    print ('4.Показать текст без знаков препинания и других символов')
    print ('Введите операцию: ')

    Попытка создать (де)кодировщик
    Оно не работает
    Интерфейс додумайте сами

    straustrup, 26 Апреля 2019

    Комментарии (30)
  3. JavaScript / Говнокод #25571

    0

    1. 1
    2. 2
    https://habr.com/ru/post/449368/
    Ко-ко-ко-ко-ко-кой багор )))

    KJlueHTcKuu_nemyx, 25 Апреля 2019

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

    +2

    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
    <?php
        define('_SECUR_GAMES', 1);
        $rootpath = '../';
        require_once '../includes/start.php';
        require_once '../includes/function.php';
        require_once '../includes/header.php';
    if($level >0 AND $fr_id!=0)
    {
    $header='alliance';
    mysql_query("UPDATE `mesto` SET `place` = '".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($header)))))))."' WHERE `uid`=".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."");
    }
    $fr=check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($_GET['f'])))))));
    $q = mysql_query("SELECT * FROM `fractions` WHERE `id`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($fr)))))))."'");
    $f = mysql_fetch_array($q);
    $ucount = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `fid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($f['id'])))))))."';"), 0);
    $fadm = mysql_result(mysql_query("SELECT COUNT(*) FROM `fractions_users` WHERE `uid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($use_id)))))))."' AND `fid`='".check(htmlspecialchars(stripslashes(addslashes(strip_tags(mysql_real_escape_string(trim($f['id'])))))))."' AND `adm`=1;"), 0);
        if($game==0 OR $level==0 OR $ban==1){
               echo "<title>Доступ закрыт!!!</title>";

    @since 2019

    eskrano, 25 Апреля 2019

    Комментарии (60)
  5. 1C / Говнокод #25568

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Функция ПолучитьСтавкуНДС(СуммаСНДС, НДС)
    	Если НДС = 0  Тогда
    		Возврат Перечисления.СтавкиНДС.БезНДС;
    	ИначеЕсли СуммаСНДС = 0 Тогда //некорректные данные
    		Возврат Перечисления.СтавкиНДС.БезНДС;
    	ИначеЕсли НДС / СуммаСНДС <= 0.152+0.0152 и НДС / СуммаСНДС >= 0.152-0.0152 Тогда
    		Возврат Перечисления.СтавкиНДС.НДС18;
    	ИначеЕсли НДС / СуммаСНДС <= 0.091+0.0091 и НДС / СуммаСНДС >= 0.091-0.0091 Тогда
    		Возврат Перечисления.СтавкиНДС.НДС10;
    	КонецЕсли;
    КонецФункции

    Костыль костыльный

    sandvich, 24 Апреля 2019

    Комментарии (32)
  6. Куча / Говнокод #25565

    0

    1. 1
    Onetime = ?config(onetime, Config) =:= true,

    Boolshit? Нет, это динамическая питуизация.

    CHayT, 24 Апреля 2019

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    #include <iostream>
    #include <string>
    #include <string_view>
    
    int main() {
      std::string s = "Hellooooooooooooooo ";
      std::string_view sv = s + "World\n";
      std::cout << sv;
    }

    https://alexgaynor.net/2019/apr/21/modern-c++-wont-save-us/
    What's happening here is that s + "World\n" allocates a new std::string, and then is converted to a std::string_view. At this point the temporary std::string is freed, but sv still points at the memory that used to be owned by it. Any future use of sv is a use-after-free vulnerability. Oops! C++ lacks the facilities for the compiler to be aware that sv captures a reference to something where the reference lives longer than the referent. The same issue impacts std::span, also an extremely modern C++ type.

    j123123, 24 Апреля 2019

    Комментарии (90)
  8. Python / Говнокод #25563

    −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
    def da_pizda(update, context):
        global da_counter, pizda_counter
    
        text = update.message.text.split()
        text = [word.lower() for word in text]
    
        if 'дa' in text or 'da' in text or 'dа' in text:
            text.append('да')
        if 'пиздa' in text or 'pizda' in text or 'pizdа' in text or 'Πизда' in text:
            text.append('пизда')
    
        if 'да' in text:
            bot.send_message(chat_id=update.message.chat_id, text='пизда',
                             reply_to_message_id=update.message.message_id)
            pizda_counter += 1
        if 'пизда' in text:
            bot.send_message(chat_id=update.message.chat_id, text='да',
                             reply_to_message_id=update.message.message_id)
            da_counter += 1
    
        da_counter += update.message.text.split().count('да')
        pizda_counter += update.message.text.split().count('пизда')

    Бот, проверяющий наличие слов "да" и "пизда" в чате телеграма, и отвечающий соответственно.

    Umerenkov21, 23 Апреля 2019

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // https://github.com/WebKit/webkit/blob/e0e7e8f907f4c01c723374e8230a63d46e89e6a0/Source/WebCore/platform/graphics/filters/FEComposite.cpp#L98
    
    static unsigned char clampByte(int c)
    {
        unsigned char buff[] = { static_cast<unsigned char>(c), 255, 0 };
        unsigned uc = static_cast<unsigned>(c);
        return buff[!!(uc & ~0xff) + !!(uc & ~(~0u >> 1))];
    }

    j123123, 22 Апреля 2019

    Комментарии (23)
  10. Си / Говнокод #25561

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    //"вирус" в стиле кулхацкеров
    #include <stdlib.h>
    int main() {
    int i = 1;
    while( i == 1)  {
    	system("start calc");
    }
    return 0;
    }

    pozhiloy, 22 Апреля 2019

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