1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #18773

    +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
    function cashBonusCalculator(currentDepositValue, el) {
        var $scope = el;
    
        if (!currentDepositValue) {
            currentDepositValue = 0;
        }
        var max_bonus_01 = $scope.find('[name="progr_step_01_max"]'),
            max_bonus_02 = $scope.find('[name="progr_step_02_max"]'),
            max_bonus_03 = $scope.find('[name="progr_step_03_max"]'),
            bonus_start_01 = $scope.find('[name="progr_step_01_start"]'),
            bonus_start_02 = $scope.find('[name="progr_step_02_start"]'),
            bonus_start_03 = $scope.find('[name="progr_step_03_start"]'),
            bonus_amount_01 = $scope.find('[name="progr_step_01_amount"]'),
            bonus_amount_02 = $scope.find('[name="progr_step_02_amount"]'),
            bonus_amount_03 = $scope.find('[name="progr_step_03_amount"]');
    
            if (cash_bonuses_list[0]) {
                max_bonus_01.text('max ' + cash_bonuses_list[0].maxbonus.toMonetaryString());
                bonus_start_01.text(cash_bonuses_list[0].f.toMonetaryString());
                bonus_amount_01.text(cash_bonuses_list[0].bonus + '%');
                main_gift_conditions.text('x' + cash_bonuses_list[0].wager + ' ' + wagerType +'; ' + cash_bonuses_list[0].ttl + _('h'));
                gift_progress.addClass('cash_gift_progress_level_01');
            }
            if (cash_bonuses_list[1]) {
                max_bonus_02.text('max ' + cash_bonuses_list[1].maxbonus.toMonetaryString());
                bonus_start_02.text(cash_bonuses_list[1].f.toMonetaryString());
                bonus_amount_02.text(cash_bonuses_list[1].bonus + '%');
                main_gift_conditions.text('x' + cash_bonuses_list[1].wager + ' ' + wagerType + '; ' + cash_bonuses_list[1].ttl + _('h'));
                gift_progress.addClass('cash_gift_progress_level_02');
            }
            if (cash_bonuses_list[2]) {
                max_bonus_03.text('max ' + cash_bonuses_list[2].maxbonus.toMonetaryString());
                bonus_start_03.text(cash_bonuses_list[2].f.toMonetaryString());
                bonus_amount_03.text(cash_bonuses_list[2].bonus + '%');
                main_gift_conditions.text('x' + cash_bonuses_list[2].wager + ' ' + wagerType + '; ' + cash_bonuses_list[2].ttl + _('h'));
                gift_progress.addClass('cash_gift_progress_level_03');
            }
    
            if (window.CASHBONUSES && window.CASHBONUSES.length > 0) {
                var progressSteps = 3;
                if (cash_bonuses_list[0]) {
                    progressSteps = 1;
                }
                if (cash_bonuses_list[1]) {
                    progressSteps = 2;
                }
                if (cash_bonuses_list[2]) {
                    progressSteps = 3;
                }
    
                if (cash_bonuses_list[0] && currentDepositValue <= cash_bonuses_list[0].t && currentDepositValue >= cash_bonuses_list[0].f) {
                    $scope.find('[name="cash_gift_progressbar"]').css({
                        width: (((main_progress_width / progressSteps) * ( (currentDepositValue - cash_bonuses_list[0].f) / (((cash_bonuses_list[0].t - cash_bonuses_list[0].f) / 100)) * 0.01))) + 'px'
                    });
                    main_gift_amount.text(cash_bonuses_list[0].c + ' ' + currentBonusSumm(cash_bonuses_list[0].bonus, cash_bonuses_list[0].maxbonus, fromCashDepositValue));
                } else if (!cash_bonuses_list[1] && cash_bonuses_list[0] && currentDepositValue > cash_bonuses_list[0].t && currentDepositValue >= cash_bonuses_list[0].f){
                    $scope.find('[name="cash_gift_progressbar"]').css({
                        width: '100%'
                    });
                    main_gift_amount.text(cash_bonuses_list[0].c + ' ' + currentBonusSumm(cash_bonuses_list[0].bonus, cash_bonuses_list[0].maxbonus, fromCashDepositValue));
                } else if (cash_bonuses_list[1] && currentDepositValue <= cash_bonuses_list[1].t && currentDepositValue >= cash_bonuses_list[1].f) {
                    $scope.find('[name="cash_gift_progressbar"]').css({
                        width: (((main_progress_width / progressSteps) * ( (currentDepositValue - cash_bonuses_list[1].f) / (((cash_bonuses_list[1].t - cash_bonuses_list[1].f) / 100)) * 0.01)) + (main_progress_width / progressSteps)) + 'px'
                    });
                    main_gift_amount.text(cash_bonuses_list[1].c + ' ' + currentBonusSumm(cash_bonuses_list[1].bonus, cash_bonuses_list[1].maxbonus, fromCashDepositValue));
                } else if (!cash_bonuses_list[2] && cash_bonuses_list[1] && currentDepositValue > cash_bonuses_list[1].t && currentDepositValue >= cash_bonuses_list[1].f){
                    $scope.find('[name="cash_gift_progressbar"]').css({
                        width: '100%'
                    });
                    main_gift_amount.text(cash_bonuses_list[1].c + ' ' + currentBonusSumm(cash_bonuses_list[1].bonus, cash_bonuses_list[1].maxbonus, fromCashDepositValue));
                } else if (cash_bonuses_list[2] && currentDepositValue <= cash_bonuses_list[2].maxbonus && currentDepositValue >= cash_bonuses_list[2].f){
                    $scope.find('[name="cash_gift_progressbar"]').css({
                        width: (((main_progress_width / progressSteps) * ( (currentDepositValue - cash_bonuses_list[2].f) / (((cash_bonuses_list[2].maxbonus - cash_bonuses_list[2].f) / 100)) * 0.01)) + ((main_progress_width / progressSteps) * 2)) + 'px'
                    });

    ambt, 28 Сентября 2015

    Комментарии (1)
  3. PHP / Говнокод #18767

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private function check($data) {
    	$result = $this->checkData($data);
    	if ($result === true) return true;
    	$sm = new SystemMessage();
    	return $sm->message($result);
    }
    protected function checkData($data) {
    	return false;
    }

    С видеокурса Михаила Русакова

    REMOX, 27 Сентября 2015

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

    +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
    import std.io;
    import std.string;
    import calendar.month;
    
    module calendar.date;
    
    namespace Chrono
    {
        export
        struct Date {
            Date(int, Month, int);
            int day() const
            {
                return d;
            }
            Month month() const
            {
                return m;
            }
            Int year() const
            {
                return y;
            }
        private:
            int d;
            Month m;
            int y;
        };
        export
        std::ostream &operator<<(std::ostream &, const Date &);
        export
        std::string to_string(const Date &);
    }

    По мотивам: http://habrahabr.ru/company/infopulse/blog/267781/
    зы. https://github.com/isocpp/CppCoreGuidelines/blob/master/talks/Large-Scale-C%2B%2B-With-Modules.pdf

    CriDos, 27 Сентября 2015

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

    +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
    class DBUSLIB_EXPORT DBusLib : public QObject
    {
        Q_OBJECT
    public:
        DBusLib(QObject* parent = 0);
        void requestId(const QString &req, const int &reqTimeOut);
    
        QByteArray replyData;
        QString name;
        MyPair reqStruct;  // id, partsCount
        QVector<QByteArray> vecFile;
        int partsCount; //кол-во частей
        int parts; //кол-во пришедших
        QTimer *timer = new QTimer(this);
    
    signals:
        void doneSignal(QByteArray& fileData);
    
    public slots:
        void requestMap(const MyPair &dbm);
        void partsFile(const MyPair &part);
        void requestFail(const QDBusError& error);
        void timeIsOver();
    
    };

    Студент принес говна. Паблик морозов, ценные комментарии и все такое.
    Вот только мне любопытна 14 строчка. C++11 не включен.
    Конпелятор mingw492 выбрасывает ворнинг
    D:\projects\test_dbus\client_v2\client_l ib\dbuslib.h:35: предупреждение: non-static data member initializers only available with -std=c++11 or -std=gnu++11
    QTimer *timer = new QTimer(this);
    ^
    Но при этом все компилится и работает. Значит, 03 стандарт разрешает такое?

    scp, 17 Сентября 2015

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

    +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
    class Program
    {
            static void Main()
            {
                UInt64 num;
                Console.WriteLine(num = F(Convert.ToUInt64(Console.ReadLine())));
                Main();
            }
    
            static UInt64 F(UInt64 number)
            {
                return number <= 0 ? 1 : number * F(number - 1);
            }
    }

    Считывание числа и выдача его факториала while(true).

    alexey_70707, 15 Сентября 2015

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

    +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
    void RedoLayout(HWND dialogWindow)
    {
    	RECT rectangle;
    	GetClientRect(dialogWindow, &rectangle);
    
    	/* Status */
    	SetWindowPos(GetDlgItem(dialogWindow, IDC_STATUS), dialogWindow, 
    		0,
    		rectangle.bottom - (layout[2].bottom - layout[2].top),
    		rectangle.right - rectangle.left,
    		(layout[2].bottom - layout[2].top),
    		SWP_NOZORDER);
    
    	/* Panel */
    	SetWindowPos(
    		GetDlgItem(dialogWindow,IDC_PANEL), dialogWindow,
    		(layout[1].left - layout[0].left),
    		(layout[1].top - layout[0].top),
    		rectangle.right - (layout[1].left-layout[0].left) - (layout[0].right - layout[1].right),
    		rectangle.bottom - (layout[1].top - layout[0].top) - (layout[0].bottom - layout[1].bottom),
    		SWP_NOZORDER);
    
    	/* Buttons & CheckBoxes */
    	for (int i = 0; i < sizeof(controls) / sizeof(controls[0]); ++i)
    	{
    		SetWindowPos(
    			GetDlgItem(dialogWindow,controls[i]), dialogWindow,
    			rectangle.right - (layout[0].right - layout[3 + i].left),
    			(layout[3 + i].top - layout[0].top),
    			(layout[3 + i].right - layout[3 + i].left),
    			(layout[3 + i].bottom - layout[3 + i].top),
    			SWP_NOZORDER);
    	}
    }

    Из SDK к Intel RealSense

    kingmonstr, 13 Сентября 2015

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

    +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
    -webkit-text-fill-color: white;
    -webkit-text-stroke-width: 1px;
    -webkit-text-stroke-color: #333;
    -moz-text-fill-color: white;
    -moz-text-stroke-width: 1px;
    -moz-text-stroke-color: #;
    text-shadow:
       1px 1px 0 #333,
     -1px -1px 0 #333,  
      1px -1px 0 #333,
      -1px 1px 0 #333,
       1px 1px 0 #333;

    Сколько нужно строчек CSS, чтобы сделать бордер у букв? (все-равно с разрывами...)

    keitoaino, 13 Сентября 2015

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

    +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
    $tel = Number::clearPhone(trim($info['telephone']));
                $allowed_chars = '1234567890';
                if (!Number::clearPhone($tel)) {
                    $errors['error'] = "Введите телефонный номер";
                    $errors[] = 'telephone';
                }
                for ($i = 0; $i < mb_strlen($tel); $i++) {
                    if (mb_strpos($allowed_chars, mb_strtolower($tel[$i])) === false) {
                        $errors['error'] = "В номере должны быть только числа";
                        $errors[] = 'telephone';
                    }
                }

    ну вот можно же было просто как-то так написать:

    preg_match('^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$', $tel)

    NotFake, 09 Сентября 2015

    Комментарии (0)
  10. JavaScript / Говнокод #18693

    +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
    var promise = new Promise(function (reject, resolve) {
    			$.ajax({
    				url: url,
    				method: method,
    				contentType: 'application/json',
    				headers: headers,
    				data: JSON.stringify(data),
    				success: function (response) {
    					resolve(response); 
    				},
    				error: function (error) {
    					reject(error);
    				}
    			});
    
    		});

    kon_simeonov, 08 Сентября 2015

    Комментарии (3)
  11. JavaScript / Говнокод #18691

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    var getVisualizerCount = function() {
        var count = 0;
        if (visualizerConfig && visualizerConfig.visualizers) {
            for (var i = 0; i < visualizerConfig.visualizers.length; i++) {
                count = count + 1;
            }
        }
        return count;
    };

    Достался проект от индусов. И такого коровьего д****а, хоть ж***й жуй. По мере нахождения запощу еще.

    uusb, 08 Сентября 2015

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