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

    +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
    96. 96
    ;;; the toplevel operators of each equation in the system
    ;;; type : array[term]
    (defmacro match-acz-state-methods (state__) `(svref ,state__ 0))
    
    ;;; functional terms
    ;;; type : array[term]
    (defmacro match-acz-state-lhs-f (state__) `(svref ,state__ 1))
    
    ;;; variables on the LHS
    ;;; type : array[term]
    (defmacro match-acz-state-lhs-v (state__) `(svref ,state__ 2))
    
    ;;; contants on the RHS
    ;;; type : array[term]
    (defmacro match-acz-state-rhs-c (state__) `(svref ,state__ 3))
    
    ;;; functional terms on RHS
    ;;; type : array[term]
    (defmacro match-acz-state-rhs-f (state__) `(svref ,state__ 4))
    
    ;;; notes repeated functional terms of LHS
    ;;; type : array[bool]
    (defmacro match-acz-state-lhs-f-r (state__) `(svref ,state__ 5))
    
    ;;; notes repeated variables of LHS
    ;;; type : array[bool]
    (defmacro match-acz-state-lhs-v-r (state__) `(svref ,state__ 6))
    
    ;;; notes repeated constants of RHS
    ;;; type : array[bool]
    (defmacro match-acz-state-rhs-c-r (state__) `(svref ,state__ 7))
    
    ;;; notes repreated funcational terms of RHS
    ;;; type : array[bool]
    (defmacro match-acz-state-rhs-f-r (state__) `(svref ,state__ 8))
    
    ;;; variables and funs acocunted for by RHS-c-sol
    ;;; type : fixnum
    (defmacro match-acz-state-lhs-mask (state__)  `(svref ,state__ 9))
    
    ;;; funs accounted for by RHS-c-sol
    ;;; type : fixnum
    (defmacro match-acz-state-lhs-f-mask (state__) `(svref ,state__ 10))
    
    ;;; bit vector of all repeated (> 0) terms on LHS
    (defmacro match-acz-state-lhs-r-mask (state__)  `(svref ,state__ 11))
    
    ;;; solution matrix for constants
    ;;; type : array[fixnum]
    (defmacro match-acz-state-rhs-c-sol (state__) `(svref ,state__ 12 ))
    
    ;;; max value of elements of RHS-C-sol
    ;;; type : fixnum
    (defmacro match-acz-state-rhs-c-max (state__) `(svref ,state__ 13))
    
    ;;; solutions matrix; functional terms
    ;;; type : array[fixnum]
    (defmacro match-acz-state-rhs-f-sol (state__) `(svref ,state__ 14))
    
    ;;; max value of elements of RHS-f-sol
    ;;; type : fixnum
    (defmacro match-acz-state-rhs-f-max (state__) `(svref ,state__ 15))
    
    ;;; type : fixnum 11111 ... 1111
    (defmacro match-acz-state-rhs-full-bits (state__) `(svref ,state__ 16))
    
    ;;; array of compatibility bitvectors; constants
    ;;; type : array[fixnum]
    (defmacro match-acz-state-rhs-c-compat (state__) `(svref ,state__ 17))
    
    ;;; array of compatibility bitvectors; funcs
    ;;; type : array[fixnum]
    (defmacro match-acz-state-rhs-f-compat (state__) `(svref ,state__ 18))
    
    ;;; number of constants on LHS after simplification
    ;;; type : fixnum
    (defmacro match-acz-state-lhs-c-count (state__) `(svref ,state__ 19))
    
    ;;; number of functions on LHS after simplification
    ;;; type : fixnum
    (defmacro match-acz-state-lhs-f-count (state__) `(svref ,state__ 20))
    
    ;;; number of variables on LHS after simplification
    ;;; type : fixnum
    (defmacro match-acz-state-lhs-v-count (state__) `(svref ,state__ 21))
    
    ;;; number of constants on RHS after simplification
    ;;; type : fixnum
    (defmacro match-acz-state-rhs-c-count (state__)  `(svref ,state__ 22))
    
    ;;; number of functions on RHS after simplification
    ;;; type : fixnum
    (defmacro match-acz-state-rhs-f-count (state__) `(svref ,state__ 23))
    
    ;;; t iff all solutions have been reported.
    (defmacro match-acz-state-no-more (state__) `(svref ,state__ 24))

    https://github.com/CafeOBJ/cafeobj/blob/master/chaos/e-match/match-acz.lisp

    ГОМОИКОНЫ копипаст лиспе
    CafeOBJ is a most advanced formal specification language which inherits many advanced features (e.g. flexible mix-fix syntax, powerful and clear typing system with ordered sorts, parameteric modules and views for instantiating the parameters, and module expressions, etc.) from OBJ (or more exactly OBJ3) algebraic specification language.

    CafeOBJ is a language for writing formal (i.e. mathematical) specifications of models for wide varieties of software and systems, and verifying properties of them. CafeOBJ implements equational logic by rewriting and can be used as a powerful interactive theorem proving system. Specifiers can write proof scores also in CafeOBJ and doing proofs by executing the proof scores.

    CafeOBJ has state-of-art rigorous logical semantics based on institutions. The CafeOBJ cube shows the structure of the various logics underlying the combination of the various paradigms implemented by the language. Proof scores in CafeOBJ are also based on institution based rigorous semantics, and can be constructed using a complete set of proof rules

    j123123, 20 Декабря 2018

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

    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
    class Cat {
      constructor(
        public name: string) {
      }
      toCoolCat(coolness: number): CoolCat {
        return new CoolCat(this.name, coolness);
      }
    }
    // ...
    class CoolCat extends Cat {
      constructor(
        name: string,
        public coolness: number) {
    
        super(name);
      }
    }
    //...
    function addCoolCat(coolness: number, cat: Cat): void {
      this.coolCats.push(cat.toCoolCat(coolness);
    }
    //...
    addCoolCat(80, {name: 'Greycat'});

    Вроде TypeScript, а на самом деле NotCompletelyTypeScript.
    Во время выполнения получим ошибку "cat.toCoolCat is not a function". Тем не менее, компилятор TypeScript позволяет это (а конкретно, строку 23) скомпилировать. Хотелось бы, чтобы не позволял.

    wissenstein, 19 Декабря 2018

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

    −2

    1. 1
    Есть те, кто вопреки IT-культуре, не зассыт написать свою зп?

    Есть те, кто вопреки IT-культуре, не зассыт написать свою зп?

    crestoblyad, 18 Декабря 2018

    Комментарии (85)
  4. Си / Говнокод #25202

    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
    enum crap
    {
        shit = 0,
        fuck,
        dick,
        ass,
        turd,
        fart,
    };
    
    static char *crap_to_str(int crap)
    {
        switch (crap)
        {
            case shit:
            {
                return "shit";
            }
            case fuck:
            {
                return "fuck";
            }
            case dick:
            {
                return "dick";
            }
            case ass:
            {
                return "ass";
            }
            case turd:
            {
                return "turd";
            }
            case fart:
            {
                return "fart";
            }
            default:
            {
                return "!!!UNKNOWN CRAP!!!";
            }
        }
    }

    Есть ли возможность через какую-нибудь плюсовую метушню с шаблонами, констэспрами и препроцессором нагенерировать подобную хрень из готового определения структуры?

    j123123, 18 Декабря 2018

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

    −2

    1. 1
    Кто рад из местных своей работой на галере?

    Кто рад из местных своей работой на галере?

    crestoblyad, 16 Декабря 2018

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

    −1

    1. 1
    Почему пхпшники получают поболя крестоблядей?

    Почему пхпшники получают поболя крестоблядей?

    crestoblyad, 16 Декабря 2018

    Комментарии (209)
  7. Swift / Говнокод #25197

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    scheduler.queue.async { [weak self] in
                guard let weakself = self else {
                    return
                }
                
                let locations = weakself.interactor

    kyzmitch, 16 Декабря 2018

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

    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
    #include <stdio.h>
    #include <conio.h>
    int main()
    {
    	int c;
    	while (1)
    	{
    		c=getch();
    		printf("%c",c/20);
    	}
    	return 0;
    }

    Шифратор 228

    PodvalniyHacker, 15 Декабря 2018

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    Кстати, разные эпизоды из Зеленого слоника можно сопоставить с разными статьями
    о C++. Если статья про какие-то новые возможности, которые вводятся в
    каком-нибудь С++20, это когда братишке покушать принесли. Если статья о том,
    как можно метапрограммировать на шаблонах, то это когда вилкой говно чистить.

    Ну что ты! Я тебе сейчас расскажу, вот смотри, Я тебе хорошую сейчас расскажу! Смотри, я… вот у нас здесь копипаста много… ой-ой… копипаста много, понимаешь? Смотри, копипаст, они тебе код читать мешает. А я вот, давай я здесь напишу метушни на темплейтах и консэкспрах с препроцессором сишным, и весь копипаст сокращу слышишь? Ну что, писать?

    j123123, 15 Декабря 2018

    Комментарии (21)
  10. PHP / Говнокод #25191

    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
    <?php
    if(isset($_GET['action']) && $_GET['action']=="add"){
            $id=intval($_GET['id']);
            if(isset($_SESSION['cart'][$id])){
            $_SESSION['cart'][$id]['quantity']++;
            }else{
    $sql_s="SELECT * FROM products
    WHERE id_product={$id}";
    $query_s=mysqli_query($sql_s);
    if(mysqli_num_rows($query_s)!=0){
    $row_s=mysqli_fetch_array($query_s);
                    $_SESSION['cart'][$row_s['id_product']]=array(
                    "quantity" => 1,
                    "price" => $row_s['price']  );
                    }else{
                    $message="This product id it's invalid!"; } } } ?>
    <h1>Product List</h1>
                    <?php
                   if(isset($message)){
                   echo "<h2>$message</h2>";  }
                   ?>
    <table>
    <tr>
                <th>Name</th>
                <th>Description</th>
                <th>Price</th>
                <th>Action</th>
    </tr>
            <?php
    $mysqli = new mysqli('……','root','……','tutorials');
    $sql = 'SELECT name,description,price, id_product FROM products'; // select from mysql
    $result = $mysqli->query($sql);  
    while($row = $result->fetch_array()){
        ?>
            <tr>
                <td><?php echo $row['name'] ?></td>
                <td><?php echo $row['description'] ?></td>
                <td><?php echo $row['price'] ?>$</td>
    <td><a href="index.php?page=products&action=add&id=<?php echo $row['id_product'] ?>">Add to cart</a></td>
            </tr>
    <?php
        }
    ?>
    </table>

    строки:
    2 - Входящую переменную так никто не проверяет. Есть функции filter_input
    3 - $_GET['id'] без проверки на существовании
    9 - mysqli_query - 1) аргумент, Идентификатор соединения. 2) сам запрос
    10 - процесс проверки num_rows глупый. Есть 0 ( ложь ), либо в остальных случаях истина.
    12 - мы выбивали из запроса id_product чтобы узнать и подставить значение как ключ $_SESSION['cart'][$row_s['id_product']] ??? Уверяю, я знаю уже ключ: $_SESSION['cart'][$id]
    30 - Глупая, тупая ошибка новичков. Постоянно на каждой логике кода, устанавливают новое соединение с бд. Нравится в постели оргия, любите много и сразу?

    Говнокодер: rita345
    https://php.ru/forum/threads/this-product-id-its-invalid.74253/

    MouseZver, 13 Декабря 2018

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