1. JavaScript / Говнокод #17348

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    express_static = express.static(static_files.file_path)
        app.use('/files', (req, res, next) ->
            if Math.random() > app.failureProbability
                express_static.handle(req, res, next)
            else
                # server failure or timeout
                if Math.random() < 0.5
                    console.log('\x1B[31mRandom failure\x1B[0m')
                    res.send(500, 'Fuck you')
                else
                    console.log('\x1B[31mRandom timeout\x1B[0m')
        )

    а вот так мы тестируем сетевую нагрузку (нода, кофе)

    makc3d, 21 Декабря 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    anim.object.strokeWidthEnd = _.distance((end.replace(/(#[0-9a-f]{6})|(#[0-9a-f]{3})|(rgba?\((\d{1,3})\,\s*(\d{1,3})\,\s*(\d{1,3})(\,\s*([0-9\.]{1,4}))?\))|(rgba?\((\d{1,3})\%?\,\s*(\d{1,3})\%?\,\s*(\d{1,3})\%?(\,\s*([0-9\.]{1,4}))?\))/, '').match(/(\d+|(\d+)?\.\d+)(em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|px|pt|pc)?/) || [])[0]);
    if(end.indexOf('transparent') > -1)
        anim.object.strokeColorEnd = [anim.object.strokeColor[0], anim.object.strokeColor[1], anim.object.strokeColor[2], 0];
    else
        anim.object.strokeColorEnd = _.color((end.match(/(#[0-9a-f]{6})|(#[0-9a-f]{3})|(rgba?\((\d{1,3})\,\s*(\d{1,3})\,\s*(\d{1,3})(\,\s*([0-9\.]{1,4}))?\))|(rgba?\((\d{1,3})\%?\,\s*(\d{1,3})\%?\,\s*(\d{1,3})\%?(\,\s*([0-9\.]{1,4}))?\))/) || end.match(new RegExp(Object.keys(_.colors).join('|'))) || [])[0]);

    одна-проблема-и-регулярка.jpg

    gost, 20 Декабря 2014

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

    +78

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public static void create(String title, int width, int height) {
            if (isWindowCreated())
                throw new RuntimeException("Window created.");
            if (title == null)
                throw new NullPointerException("Window title == null.");
            if (width <= 0 || height <= 0)
                throw new IllegalArgumentException("Window size <= 0.");
            if ((window = GLFW.glfwCreateWindow(width, height, title, MemoryUtil.NULL, MemoryUtil.NULL)) == MemoryUtil.NULL)
                throw new RuntimeException("Failed to create the GLFW window.");
        }

    jangolare, 20 Декабря 2014

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

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    var resultList = new List<CentralBankRateData>();
    using (var resultSet = m_Service.GetCursOnDate(request.Date))
    using (var reader = new DataTableReader(resultSet.Tables["ValuteCursOnDate"]))
    	while (reader.Read())
    		resultList.Add(new CentralBankRateData
    		{
    			Name = (string) reader["Vname"],
    			Nominal = (decimal) reader["Vnom"],
    			Rate = (decimal) reader["Vcurs"],
    			NumberCode = (int) reader["Vcode"],
    			StringCode = (string) reader["VchCode"]
    		});

    Какой Центробанк, такая и валюта. m_Service типа DailyInfoSoap, это сервис отдачи курсов валют. А еще у них получение актуального списка БИКов возможно только в древнейшем формате dBASE.

    yamamoto, 19 Декабря 2014

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

    −107

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ****@****:~$ python
    >>> import this
    The Zen of Python, by Tim Peters
    <....>There should be one-- and preferably only one --obvious way to do it.<...>
    >>> exit
    Use exit() or Ctrl-D (i.e. EOF) to exit

    preferably only one

    heyzea1, 19 Декабря 2014

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

    +129

    1. 1
    CN-1489: Commit tests to isolate the bug (sadly, they pass)

    someone, 19 Декабря 2014

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

    +164

    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
    // В шаблоне вот так:
    <DIV  class="tel"><? include ("/home/***/www/inc/calend.php"); ?><BR>
    // А в файле вот так:
    <?
    
    $calend = array(
    "17.05.2014", 
    "18.05.2014", 
    "24.05.2014",
    "25.05.2014",
    "31.05.2014",
    "01.06.2014",
    "07.06.2014",
    "08.06.2014",
    "12.06.2014",
    "13.06.2014",
    "14.06.2014",
    "15.06.2014",
    "21.06.2014",
    "22.06.2014",
    "28.06.2014",
    "29.06.2014",
    "05.07.2014",
    "06.07.2014",
    "12.07.2014",
    "13.07.2014",
    "19.07.2014",
    "20.07.2014",
    "26.07.2014",
    "27.07.2014",
    "02.08.2014",
    "03.08.2014",
    "09.08.2014",
    "10.08.2014",
    "16.08.2014",
    "17.08.2014",
    "23.08.2014",
    "24.08.2014",
    "30.08.2014",
    "31.08.2014",
    "07.09.2014",
    "13.09.2014",
    "14.09.2014",
    "20.09.2014",
    "21.09.2014",
    "27.09.2014",
    "28.09.2014",
    "04.10.2014",
    "05.10.2014",
    "11.10.2014",
    "12.10.2014",
    "18.10.2014",
    "19.10.2014",
    "25.10.2014",
    "26.10.2014",
    "01.11.2014",
    "02.11.2014",
    "03.11.2014",
    "04.11.2014",
    "08.11.2014",
    "09.11.2014",
    "15.11.2014",
    "16.11.2014",
    "22.11.2014",
    "23.11.2014",
    "29.11.2014",
    "30.11.2014",
    "07.12.2014",
    "13.12.2014",
    "14.12.2014",
    "20.12.2014",
    "21.12.2014",
    "27.12.2014",
    "28.12.2014"
    );
    
    
    
    if (in_array(date("d.m.Y",time()), $calend)) {
    echo "(343) 266-30-54";
    }
    
    else echo '(343) 222-77-60';
    
    
    
    
    
    ?>

    Это так вот происходит подмена телефона в выходные дни, да.

    Shimmy, 19 Декабря 2014

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

    +156

    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
    <?php
    foreach ($details->result_array() as $row) {
        $name = $row['name'];
        $email = $row['email'];
        $avatar = $row['avatar'];
        $access = $row['access'];
        $notify = $row['notify'];
        $notifysms = $row['notifysms'];
        $mobile = $row['mobile'];
        $signature = $row['signature'];
    
        $address = $row['address'];
        $city = $row['city'];
        $state = $row['state'];
        $zip = $row['zip'];
        $country = $row['country'];
        $phone = $row['phone'];
        $mobile = $row['mobile'];
        
        $external_state = $row['external_state'];
        $external_auth = $row['external_auth'];
    }
    ?>

    Убивает к тому же то, что этот кусок написан в файле представления. Еще спрашивают, почему я решил уволиться :)

    omegascorp, 19 Декабря 2014

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

    −120

    1. 1
    |РАЗНОСТЬДАТ(ДАТАВРЕМЯ(1980, 1, 1), НакладнаяНаОтпускМатериалы.ДатаВозврата, ДЕНЬ) + 2444240 КАК ДатаВозврата,

    Внезапно! Календарь майя

    safer_bwd, 19 Декабря 2014

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

    +48

    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
    #include <iostream>
    
    #include "msg/messagehandler.h"
    #include "msg/messagedispatcher.h"
    
    #include "kukarek.h"
    #include "pocpocpoc.h"
    
    using namespace std;
    
    class Foo : public MessageHandler
    {
    public:
        Foo(MessageDispatcher* dispatcher):
            MessageHandler(dispatcher)
        {
            using namespace std::placeholders;
            subscribe<Kukarek>(bind(&Foo::kukarek, this, _1));
        }
    
        void foo()
        {
            sendMessage(PocPocPoc{5});
        }
    
        void kukarek(const Kukarek& k)
        {
            cout << "Foo Kukarek " << k.i << endl;
        }
    };
    
    class Bar : public MessageHandler
    {
    public:
        Bar(MessageDispatcher* dispatcher):
            MessageHandler(dispatcher)
        {
            using namespace std::placeholders;
            subscribe<PocPocPoc>(bind(&Bar::pocpocpoc, this, _1));
            subscribe<Kukarek>(bind(&Bar::kukarek, this, _1));
        }
    
        void bar()
        {
            sendMessage(Kukarek{42});
        }
    
        void kukarek(const Kukarek& k)
        {
            cout << "Bar Kukarek " << k.i << endl;
        }
    
        void pocpocpoc(const PocPocPoc& p)
        {
            cout << "Bar PocPocPoc " << p.j << endl;
        }
    };
    
    int main()
    {
        MessageDispatcher dispatcher;
        Foo f(&dispatcher);
        Bar b(&dispatcher);
        cout << "Hello World!" << endl;
        f.foo();
        b.bar();
        return 0;
    }

    Hello World!
    Bar PocPocPoc 5
    Foo Kukarek 42
    Bar Kukarek 42
    https://code.google.com/p/message-poc-poc-poc/

    DlangGovno, 18 Декабря 2014

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