1. C# / Говнокод #25992

    0

    1. 1
    let res: boolean = result.lmr_customertype === typeOfSaleValue ? false : true;

    m_sandman, 25 Октября 2019

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    char (&getArray())[11] {
      static char arr[] = "1234567890";
      return arr;
    }

    Как вернуть массив из функции в C/C++

    На самом деле нет: возвращается ссылка

    Elvenfighter, 24 Октября 2019

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

    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
    public class HttpQueryNameValueCollection : NameValueCollection
        {
            private ParallelLoopResult _parallelLoopResult;
    
            public override string ToString()
            {
                List<string> result;
                result = new List<string>();
                _parallelLoopResult = Parallel.ForEach(AllKeys, p =>
                {
                    if (BaseGet(p) != null)
                        result.Add(p + "=" + Get(p));
                });
                return string.Join("&", result);
            }
        }

    Формирование ссылки с query-параметрами недостаточно быстро, поэтому нужно это сделать в параллель :D

    adoconnection, 24 Октября 2019

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // This concept tests whether 't + u' is a valid expression
    template<typename T, typename U>
    concept can_add = requires(T t, U u) { t + u; };
     
    // The function is only a viable candidate if 't + u' is a valid expression
    template<typename T, typename U> requires can_add<T, U>
    auto add(T t, U u)
    {
     return t + u;
    }

    ого чо есть

    MAPTbIwKA, 24 Октября 2019

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

    0

    1. 1
    2. 2
    var q = jQuery('#expand-trigger').text().replace('Привет, ', '').replace('!', '');
    console.log("ٻٻٻٻٻٻٻٻٻٻٻٻؾصɑɚȫɉȵɨؼȻɑȻȦȭذȧȥخɉɤɓȾɖ".split("").map((c, i) => String.fromCharCode(c.charCodeAt() ^ q.charCodeAt(i % q.length) ^ 1659)).join(""));

    3_dar, 23 Октября 2019

    Комментарии (43)
  6. Lua / Говнокод #25987

    0

    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
    local money = 0
    local auto_money = 0
    local auto_money_lvl = 0
    local auto_money_buy = 50
    local bonus_money_lvl = 0
    local bonus_money_buy = 35
    local json_pip = require("json")
    local bacg = display.newRect(0,0,1080,1920)
    local button = display.newRect(160,190,175,175)
    button:setFillColor(0,0.4,0.3)
    local button_auto = display.newRect(70,400,111,111)
    button_auto:setFillColor(0,0.4,0.3)
    local button_bonus = display.newRect(250,400,111,111)
    button_bonus:setFillColor(0,0.4,0.3)
    local text = display.newText("Click", 161, 190, "consolas", 30)
    text:setFillColor(1,1,1)
    local text1 = display.newText("Money:", 64, -19, "consolas", 30)
    text1:setFillColor(0,0.1,0.8)
    local text2 = display.newText(money, 200, -16, "consolas", 30)
    text2:setFillColor(0,0.1,0.8)
    local text3 = display.newText("Auto", 70, 370, "consolas", 30)
    text3:setFillColor(1,1,1)
    local text4 = display.newText("click", 70, 400, "consolas", 30)
    text4:setFillColor(1,1,1)
    local text5 = display.newText(auto_money_buy, 70, 437, "consolas", 30)
    text5:setFillColor(1,1,1)
    local text6 = display.newText("Bonus", 250, 370, "consolas", 30)
    text6:setFillColor(1,1,1)
    local text7 = display.newText("click", 250, 400, "consolas", 30)
    text7:setFillColor(1,1,1)
    local text8 = display.newText(bonus_money_buy, 250, 437, "consolas", 30)
    text8:setFillColor(1,1,1)
    ocal button_shadow = display.newRect(160,280,175,10)
    button_shadow:setFillColor(0,0.3,0.4)
    local button_shadow_auto = display.newRect(70,460,111,10)
    button_shadow_auto:setFillColor(0,0.3,0.4)
    local button_shadow_bonus = display.newRect(250,460,111,10)
    button_shadow_bonus:setFillColor(0,0.3,0.4)
    local copyright = display.newText("KernelCoreSW 2018-2019", 163, 490, "consolas", 23)
    copyright:setFillColor(0,0.1,0.8)
    local function flapBird (event)
      if(event.phase == "began") then
       ---lvl
       if(bonus_money_lvl == 0) then
         money = money + 1
        end
        if(bonus_money_lvl == 1) then
         money = money + 2
        end
    --И еще такого говнаролла штук 10
    text2.text = money
    end
    local function flapBird_bonus (event)
      if(event.phase == "began") then
        if(money >= bonus_money_buy) then
         money = money - bonus_money_buy
         bonus_money_buy = bonus_money_buy * 3
         bonus_money_lvl = bonus_money_lvl + 1
        end
        text2.text = money
        text8.text = bonus_money_buy
      end
    end
    local function onUpdate (args)
    
        if(auto_money > 40) then
      auto_money = 0
        end    
        ---------levels
        if(auto_money_lvl == 1) then
      if(auto_money == 40) then
       money = money + 1
       text2.text = money
      end
        end
        ---------levels end и еще такого говна штук 10
        auto_money = auto_money + 1
    end
    local function load_settings(fileName)
        local path = system.pathForFile(fileName, system.ResourceDirectory)
        local contents = ""
        local myTable = {}
        local file = io.open(path, "r")
        if(file) then
      contents = file:read("*a")
      myTable = json.decode(contents)
      io.close(file)
      return myTable
        end
        return nil
    end
    local settings = loadSettings("settings.json")
    if(settings) then
        money = settings.money
        auto_money = settings.auto_money
        auto_money_buy = settings.auto_money_buy
        auto_money_lvl = settings.auto_money_lvl
        bonus_money_lvl = settings.bonus_money_lvl
        bonus_money_buy = settings.bonus_money_buy
    end

    button:addEventListener("touch", flapBird)
    button_auto:addEventListener("touch", flapBird_auto)
    button_bonus:addEventListener("touch", flapBird_bonus)
    Runtime:addEventListener("enterFrame", onUpdate)

    Гейдев.

    3oJIoTou_xyu, 23 Октября 2019

    Комментарии (191)
  7. Python / Говнокод #25986

    +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
    class Container:
        def __init__(self, liquid):
            self.liquid = liquid
    
        def look_inside(self):
            return f"{self.liquid} in container"
    
        @classmethod
        def create_with(cls, liquid):
            return cls(liquid)
    
    
    class Bottle(Container):
        def look_inside(self):
            return f"bottle full of {self.liquid}"
    
    
    class Glass(Container):
        def look_inside(self):
            return f"A glass of {self.liquid}"
    
    
    for c in (c.create_with("beer") for c in [Glass, Bottle]):
        print(c.look_inside())

    ми маємо class polymorphism

    DypHuu_niBEHb, 23 Октября 2019

    Комментарии (8)
  8. bash / Говнокод #25985

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    set -e
    
    myfunc() {
      echo "START"
      v=$(asdasdsd 1 2 3)
      echo "FINISH"
    }
    
    myfunc && echo "OK"

    Выводит:

    START
    ./b.sh: line 5: asdasdsd: command not found
    FINISH
    OK

    asdasdsd - несуществующая команда, вызывающая падение скрипта

    Помогите сделать так, чтобы ошибку можно было поймать, и чтобы до echo "FINISH" не доходило.
    Уже всё перепробовал. Нерабочие вореанты просьба не предлагать.



    Вот так работает правильно
    set -e

    myfunc() {
    echo "START"
    v=$(asdasdsd 1 2 3)
    echo "FINISH"
    }

    myfunc


    Выводит:
    START
    ./a.sh: line 5: asdasdsd: command not found

    Но мне нужно ошибку перехватить.

    guestinxo, 22 Октября 2019

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

    −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
    ВЫБОР КОГДА ПОДСТРОКА(Поле, 1, 1) <> ""-"" ТОГДА
      ПОДСТРОКА(Поле, 1, 1)
    ИНАЧЕ """"
    КОНЕЦ
    +
    ВЫБОР КОГДА ПОДСТРОКА(Поле, 2, 1) <> ""-"" ТОГДА
      ПОДСТРОКА(Поле, 2, 1)
    ИНАЧЕ """"
    КОНЕЦ
    +
    ...
    +
    ВЫБОР КОГДА ПОДСТРОКА(Поле, 100, 1) <> ""-"" ТОГДА
      ПОДСТРОКА(Поле, 100, 1)
    ИНАЧЕ """"
    КОНЕЦ

    Реализация СтрЗаменить() в запросе

    DioSoset, 22 Октября 2019

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>
    <p oncopy="return false" ondragstart="return false"></p>

    Защита контента для самых маленьких

    bootcamp_dropout, 22 Октября 2019

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