1. Куча / Говнокод #27429

    0

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

    #57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
    #58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
    #59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
    #60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
    #61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
    #62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
    #63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
    #64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
    #65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
    #66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
    #67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
    #68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280
    #82: https://govnokod.ru/27284 https://govnokod.xyz/_27284
    #83: https://govnokod.ru/27296 https://govnokod.xyz/_27296
    #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

    nepeKamHblu_nemyx, 16 Мая 2021

    Комментарии (2998)
  2. JavaScript / Говнокод #27428

    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
    enum En {
            A,
            B,
            C,
            D = 4200,
            E,
        }
    
        enum En2 {
            D0 = En.D,
            D1,
            D2 = 1,
        }
    
    function main()
    {
    	const a = En.A;
    	print (a, En.B, En.C, En.D);
    	print (En2.D0, En2.D1, En2.D2);
    }

    output: >>
    0 1 2 4200
    4200 1 1

    Ну что.. учись "С" как enum-ы делать надо....

    ASD_77, 14 Мая 2021

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Inductive my_bool :=
    | my_false
    | my_true.
    
    Theorem shit_happens:
      (if my_false then 42 else 100500) = 42.
    Proof.
      reflexivity.
    Qed.

    Какая типизация )))

    bormand, 14 Мая 2021

    Комментарии (70)
  4. Python / Говнокод #27426

    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
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    from colorama import init, Fore, Back, Style
    init()
    print(Back.BLACK)
    print(Fore.RED)
    print(Style.NORMAL)
    print("Script mamoeba/Скрипт сделан")
    print("┌────────────────────────────────────┐")
    print("│Author : GovnoCode user                  │")
    print("│Github : https://:/│")
    print("└────────────────────────────────────┘")
    print("YouTube: utube")
    print("▄▀▄ █▄░▄█ ▀ █▄░█ ▄▀▄ ▄▀▄ █▀▄ ▐▌░▐▌ █▀▄ ▄▀▄")
    print("█▀█ █░█░█ █ █░▀█ █░█ █▀█ █░█ ░▀▄▀░ █▀█ █░█")
    print("▀░▀ ▀░░░▀ ▀ ▀░░▀ ░▀░ ▀░▀ ▀▀░ ░░▀░░ ▀▀░ ░▀░")
    print("Advertise Bot Amino")
    lz = []
    from concurrent.futures import ThreadPoolExecutor
    import concurrent.futures
    import amino
    def advertise(data):
        listusers = []
        for userId in data.profile.userId:
            listusers.append(userId)
        return listusers
        
    email = input("Email/Почта: ")
    password = input("Password/Пароль: ")
    msg = input("Message/Сообщение: ")
    client = amino.Client()
    client.login(email=email, password=password)
    clients = client.sub_clients(start=0, size=1000)
    for x, name in enumerate(clients.name, 1):
        print(f"{x}.{name}")
    communityid = clients.comId[int(input("Выберите сообщество/Select the community: "))-1]
    sub_client = amino.SubClient(comId=communityid, profile=client.profile)
    users = sub_client.get_online_users(size=1000)
    user = advertise(users)
    for i in lz:
            if i in user:
                user.remove(i)
         
            
    print("Sending Advertise")
    for _ in range(4000):
        with concurrent.futures.ThreadPoolExecutor(max_workers=40000) as executor:
            _ = [executor.submit(sub_client.start_chat, user, msg) for userId in user]
    
    print("Sending Advertise 2")
    for _ in range(4000):
        with concurrent.futures.ThreadPoolExecutor(max_workers=40000) as executor:

    Flow, 13 Мая 2021

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

    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
    function main()
    {
      let a: [string, number] = ["asd", 1.0];
      print(a[0], a[1]);  
    
    
      const b: [string, number] = ["asd", 1.0];
      print(b[0], b[1]);  
    
      const c = ["asd", 1.0];
      print(c[0], c[1]);  
    }

    Продолжаем будни говнописания говнокомпилятора. Хотел спросить а ваш компилятор может так, но думаю может. В кратце - это работа с таплами(tuples) а не с масивами :)

    ASD_77, 13 Мая 2021

    Комментарии (44)
  6. C++ / Говнокод #27424

    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
    struct X {
        int x;
        int y;
    
        X(int y_) :
            y(y_),
            x(y + 10)
        {
        }
    };
    
    int main()
    {
        X foo = X(16);
        std::cout << "foo == (" << foo.x << ", " << foo.y << ")" << std::endl;
    }

    PolinaAksenova, 12 Мая 2021

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

    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
    // Приведение численного типа к структуре с битовыми полями
    template <class STRUCT_T, typename T>
    STRUCT_T struct_cast(const T n)
    {
        static_assert(std::is_integral<T>::value, "Integral type required as T");
        static_assert(std::is_class<STRUCT_T>::value, "class or struct type required as STRUCT_T");
        static_assert(sizeof(T) == sizeof(STRUCT_T), "Incompatible types passed");
    
        return *(reinterpret_cast<const STRUCT_T*>(&n));
    }
    
    // Приведение структур с битовыми полями к численному типу
    template <typename T, class STRUCT_T>
    T integral_cast(const STRUCT_T& s)
    {
        static_assert(std::is_integral<T>::value, "Integral type required as T");
        static_assert(std::is_class<STRUCT_T>::value, "class or struct type required as STRUCT_T");
        static_assert(sizeof(T) == sizeof(STRUCT_T), "Incompatible types passed");
    
        return *(reinterpret_cast<const T*>(&s));
    }

    Почему это UB?

    YpaHeLI_, 12 Мая 2021

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

    +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
    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
    <?php
    
    function syoma_verify_spam($comment_post_ID) {
        // NOTE: На telegram этот метод не вызывается
    
        $content = trim($_POST['comment']);
        if (preg_match('#<a href=#', $content) && !preg_match('#\[code#', $content)) {
            die('Ня, пока.');
        }
        $content = strip_tags(apply_filters('gk_content', $content));
        $content = strtr($content, array(
            'A' => 'А',
            'a' => 'а',
            'B' => 'В',
            'E' => 'Е',
            'e' => 'е',
            '3' => 'З',
            'K' => 'К',
            'k' => 'к',
            'M' => 'М',
            'H' => 'Н',
            'O' => 'О',
            'o' => 'о',
            'P' => 'Р',
            'p' => 'р',
            'C' => 'С',
            'c' => 'с',
            'T' => 'Т',
            'Y' => 'У',
            'y' => 'у',
            'X' => 'Х',
            'x' => 'х',
            'b' => 'ь',
        ));
        $content = mb_strtolower($content);
        if (preg_match('#русня|хуйло|ватник|ватный|пидораш|пидорах#', $content)) {
            die('Рус-ня, пока.');
        }
    }

    Угадайте, почему фильтрация <a href не в конце функции?

    3_dar, 12 Мая 2021

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

    0

    1. 1
    2. 2
    3. 3
    Нужно реализовать thread-safe set.
    На сколько нормально разбить сет на N бакетов (по хешу, условно, 10000 штук),
    тогда при добавлении или удалении элемента делать лок соответствующего бакета

    Но будет хуево, когда пойдут запросы по одному ключу в нескольких тредах.
    Есть решение лучше?

    3_dar, 12 Мая 2021

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

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #include <stdio.h>
    #include <stdlib.h>
    #define RW(a, c) for(src = (a);src < (c); src++, dst++){*dst=*src;} 
    void *pairscan(char *p)
    {
      size_t p_count = 1;
      do {
        if(*p == 'P') {
          p_count++;
        }
        else {
          p_count--;
        }
        p++;
      } while(p_count != 0);
      return p;
    }
    
    
    void rewrite(char *src, char *dst)
    {
      int p_r = 0;
      while(*src == 'P') {
        *dst = *src;
        src++; dst++;
        if (p_r < 3)
        {
          p_r++;
        }
      }
      if(*src == 'I') {
        if(p_r < 1) {
          while(*src != 0) {
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst--;
        src++;
        //src = pairscan(src+1);
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      if(*src == 'K') {
        if(p_r < 2)
        {
          while(*src != 0) {
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst-=2;
        char *exp1 = pairscan(src+1);
        char *exp2 = pairscan(exp1);
        RW(src+1,exp1);
        for(; src < exp2; src++){}
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      if(*src == 'S') {
        if(p_r < 3) {
          while(*src != 0){
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst-=1;
        char *exp1 = pairscan(src+1);
        char *exp2 = pairscan(exp1);
        char *exp3 = pairscan(exp2);
        RW(src+1,exp1);
        RW(exp2,exp3);    
        *dst = 'P';
        dst++;
        RW(exp1,exp2);
        RW(exp2,exp3);
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      *dst = 0;
      return;
    }

    Кобенаторная логика
    SKI combinator calculus

    j123123, 11 Мая 2021

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