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

    −6

    1. 1
    хде хруст?

    Превед, говнокод. Чому нет категории для раста?

    orion, 28 Июля 2022

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

    −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
    #include <iostream>
    #include <string>
    #include <thread>
    #include <mutex>
    #include <condition_variable>
    #include <atomic>
    #include <queue>
    
    
    std::condition_variable messages_cv;
    std::mutex messages_mtx;
    std::queue<std::string> messages;
    
    std::atomic_bool running = true; // TODO: stop_token when c++20
    
    
    void pull_messages_thread() {
        bool should_run = running;
        while (should_run) {
            std::unique_lock lock(messages_mtx);
        
            messages_cv.wait(lock, []{ return !messages.empty() || !running; });
            if (messages.empty()) return;
        
            auto message = std::move(messages.front());
            messages.pop();
        
            should_run = running || !messages.empty();
            lock.unlock();
        
            std::cout << "Processing\t" + message + "\n";
            std::this_thread::sleep_for(std::chrono::milliseconds(20));
            std::cout << "Processed\t" + message + "\n";
        }
    }
    
    
    int main() {
        std::thread puller(pull_messages_thread);
        for (std::size_t i = 0; i < 10; ++i) {
            std::string message = "Message<" + std::to_string(i) + ">";
    
            std::unique_lock lock(messages_mtx);
            std::cout << "Storing \t" + message + "\n";
            messages.emplace(std::move(message));
            lock.unlock();
            messages_cv.notify_all();
    
            std::this_thread::sleep_for(std::chrono::milliseconds(10));
        }
    
        // std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    
        running = false;
        messages_cv.notify_all();
        puller.join();
    }
    
    /*
    
    Storing 	Message<0>
    Processing	Message<0>
    Storing 	Message<1>
    Storing 	Message<2>
    Processed	Message<0>
    Processing	Message<1>
    Storing 	Message<3>
    Processed	Message<1>
    Processing	Message<2>
    Storing 	Message<4>
    Storing 	Message<5>
    Processed	Message<2>
    Processing	Message<3>
    Storing 	Message<6>
    Storing 	Message<7>
    Processed	Message<3>
    Processing	Message<4>
    Storing 	Message<8>
    Storing 	Message<9>
    Processed	Message<4>
    Processing	Message<5>
    Processed	Message<5>
    Processing	Message<6>
    Processed	Message<6>
    Processing	Message<7>
    Processed	Message<7>
    Processing	Message<8>
    Processed	Message<8>
    Processing	Message<9>
    Processed	Message<9>
    
     */

    grillow1337, 27 Июля 2022

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

    0

    1. 1
    Пиздец-оффтоп #49

    #19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
    #20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
    #21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
    #22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
    #23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
    #24: https://govnokod.ru/27501 https://govnokod.xyz/_27501
    #25: https://govnokod.ru/27521 https://govnokod.xyz/_27521
    #26: https://govnokod.ru/27545 https://govnokod.xyz/_27545
    #27: https://govnokod.ru/27572 https://govnokod.xyz/_27572
    #28: https://govnokod.ru/27580 https://govnokod.xyz/_27580
    #29: https://govnokod.ru/27738 https://govnokod.xyz/_27738
    #30: https://govnokod.ru/27751 https://govnokod.xyz/_27751
    #31: https://govnokod.ru/27754 https://govnokod.xyz/_27754
    #32: https://govnokod.ru/27786 https://govnokod.xyz/_27786
    #33: https://govnokod.ru/27801 https://govnokod.xyz/_27801
    #34: https://govnokod.ru/27817 https://govnokod.xyz/_27817
    #35: https://govnokod.ru/27822 https://govnokod.xyz/_27822
    #36: https://govnokod.ru/27826 https://govnokod.xyz/_27826
    #37: https://govnokod.ru/27827 https://govnokod.xyz/_27827
    #38: https://govnokod.ru/27833 https://govnokod.xyz/_27833
    #39: https://govnokod.ru/27862 https://govnokod.xyz/_27862
    #40: https://govnokod.ru/27869 https://govnokod.xyz/_27869
    #41: https://govnokod.ru/27933 https://govnokod.xyz/_27933
    #42: https://govnokod.ru/27997 https://govnokod.xyz/_27997
    #43: https://govnokod.ru/28042 https://govnokod.xyz/_28042
    #44: https://govnokod.ru/28080 https://govnokod.xyz/_28080
    #45: https://govnokod.ru/28086 https://govnokod.xyz/_28086
    #46: https://govnokod.ru/28105 https://govnokod.xyz/_28105
    #47: https://govnokod.ru/28166 https://govnokod.xyz/_28166
    #48: https://govnokod.ru/28229 https://govnokod.xyz/_28229

    nepeKamHblu_nemyx, 27 Июля 2022

    Комментарии (568)
  4. Java / Говнокод #28297

    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
    import java.util.InputMismatchException;
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            try {
                System.out.println("How many characters will be in the password? (1-256):");
                short length = scanner.nextShort();
                if (length > 256) {
                    System.out.println("Password can't be longer than 256 characters!");
                } else if (length < 1) {
                    System.out.println("Password can't be less than 1 character long!");
                } else {
                    System.out.println("How many passwords will be generated? (1-32)");
                    byte amount = scanner.nextByte();
                    if (amount > 32) {
                        System.out.println("You can't generate more than 32 passwords!");
                    } else if (amount < 1) {
                        System.out.println("You can't generate less than 1 password!");
                    } else {
                        for (byte i = 0; i < amount; i++) {
                            System.out.println("\n" + PasswordGenerator.generate(length));
                        }
                    }
                }
            } catch (InputMismatchException e) {
                System.out.println("Input error!");
            }
        }
    }

    cringe

    zxc254363, 27 Июля 2022

    Комментарии (0)
  5. Куча / Говнокод #28295

    0

    1. 1
    2. 2
    Какой сильный момент... Гундяеву такое не по зубам.
    https://youtu.be/Mx4yIsbb0Us?t=10869

    Священник держит в руках монстранцию, в оригинале - ящик (ковчег) с дарами.

    nPOnOBeDHuK, 26 Июля 2022

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Добрый день, частички Хаоса! С Вами говорит Прокрастинатор Сальвадор. Прошу выражать благоговения в сжатой форме.
    
    Мне давно уже надоели Ваши склоки и бессмысленное блуждание, вызванное, очевидно, броуновским движением, но дефрагментировать Вас мне лень. 
    Я слишком велик, чтобы вмешиваться в дела частиц, пребывающих в Хаосе.
    
    Лучше я погожу, пока Вы, бессмысленно двигаясь и притираясь друг к другу бочком не примете действительно ужасные формы; вот тогда-то я Вас и уничтожу.

    Если, конечно, мне будет не лень.

    nPOKPACTuHATOP, 25 Июля 2022

    Комментарии (0)
  7. Куча / Говнокод #28293

    −2

    1. 1
    бульк

    MaaKut, 23 Июля 2022

    Комментарии (0)
  8. Си / Говнокод #28292

    +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
    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    #define NUMARGS(type,...)  (sizeof((type[]){__VA_ARGS__})/sizeof(type))
    #define xDEF(type) typedef struct {size_t size; type* arr;  }  xARR(type)
    #define xARR(type) jArr_ ## type
    
    #define A(type, ...) (xARR(type)) {NUMARGS(type,__VA_ARGS__), (type[]){__VA_ARGS__}}
    
    #define _FOR(type, item, Arr) type item=Arr.arr[0]; for(size_t I = 0; I < Arr.size; item=Arr.arr[++I] ) 
    // MSVC
    #define xFOR(type, item, array) do{  _FOR(type, item, array) {
    // GCC, Clang
    #define FOR(item, array)        do{ __auto_type Arr=array; _FOR(__auto_type, item, Arr) {
        
    #define NEXT }} while(0);
    
    #define OfArray(type,arr) (xARR(type)){sizeof(arr)/sizeof(type), arr }
    
    typedef struct {
        char *name;
        int     id;
    } Entry;
    
    
    typedef struct {const char *name;} Str;
    typedef struct {int x[2]; } Pair;
    
    xDEF(Entry);
    xDEF(Str);
    xDEF(Pair);
    xDEF(int);
    
    void printEntry(xARR(Entry) entries)
    {
        xFOR(Entry, e, entries)
            printf("%s %d \n", e.name, e.id);
        NEXT
    }
    
    void printSquares(xARR(int) ints)
    {
        FOR(v, ints)
            printf("%d²=%d\n", v,(int) pow(v,2.));
        NEXT
    }
    
    int main(void)
    {
        xARR(Entry) e = A(Entry, {"one",1}, {"two",2}, {"three",3});
        printEntry(e);
        
        puts("_______________________________________");
        
        // можно передавать в метод непосредственно аргуметом
        printSquares( A(int, 3, 7, 5, 4) );
        puts("_______________________________________");    
        
        int nums[]={4,3,2,1};
        // можно использовать ранее объявленный массив
        printSquares(OfArray(int,nums));
        
        // можно итерироватьcя по ранее объявленному массиву
        FOR(i, OfArray(int, nums))
            printf("%d-",i);
        NEXT
        
        puts("\n_______________________________________");
        
        //вложенные циклы:
        for (int k=1;k<3;k++)
            FOR(i, A(Str, "kakoi", "bagor"))    
                FOR(j, A(int, 1111,2222,3333))
                    printf("%d %s %d\n", k, i.name, j);
                NEXT
            NEXT
        
        puts("_______________________________________");
        
        FOR(v, A(Pair, {1,2}, {11,12}, {20,21}))
            printf("%d,%d\n", v.x[0], v.x[1]);
        NEXT
        puts("_______________________________________");    
        //проблема пустого варарга
        FOR(j, A(int))
            printf("%d\n", j);
        NEXT    
        return(0);
    }

    https://godbolt.org/z/o9Tv9EvGx

    Довёл for~each до ума.

    3.14159265, 23 Июля 2022

    Комментарии (26)
  9. Куча / Говнокод #28291

    −4

    1. 1
    Передайте  Камрану Амини что он Большое Хуйло

    lazy_8, 22 Июля 2022

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

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Здравствуйте, друзьйа!
    Вчера вечером я познакомился с двумя маленькими лолли. Я подстерег их в кустах, когда они возвращались из школы.
    Под предлогом позаниматься математикой, мы пришли ко мне в логово, 
    где за пару учебных ништяков и подаренный блокнот мне было позволено обнюхать трусики.
    
    Большей награды мне и не нужно!..

    Pedobear, 21 Июля 2022

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