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

    +135

    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
    try
    {
    	HttpWebRequest httpWebReq = (HttpWebRequest)WebRequest.Create(this.OURURL);
    	httpWebReq.Timeout = 2000;
    	httpWebReq.Method = "POST";
    
    	string Response = ResponseStreamReader.ReadToEnd();
    	
    	// bla-bla-bla ...
    
    	httpWebReq.GetResponse().Close();
    	httpWebReq = null;
    	Response = null;
    }

    Smekalisty, 19 Августа 2014

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

    +137

    1. 1
    readonly string NEWLINE = "\r\n";

    Smekalisty, 19 Августа 2014

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

    +134

    1. 1
    2. 2
    3. 3
    class UnathorizedDevice : ArgumentException { public UnathorizedDevice() : base() { } }
    
    class LocalException : ArgumentException { public LocalException(string message) : base(message) { } }

    Говно или не говно? Мне кажется первое

    Smekalisty, 19 Августа 2014

    Комментарии (24)
  4. Куча / Говнокод #16559

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    rem Check if Windows XP or Windows 7
    rem XP: C:\Documents and Settings (or language specific folder)
    rem 7: C:\Users
    
    set oprsystem=%appdata:~3,5%
    if %oprsystem%==Users (
      set ops=win7
    ) else (
      set ops=winxp
    )

    Batch
    http://members.ferrara.linux.it/freddy77/encfs.html

    galeksandrp, 18 Августа 2014

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

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    ng-include="'views/partials/header.html'"
    - class="navbar navbar-static-fixed-top nav"></div>
    + /*class="navbar navbar-static-fixed-top nav"*/></div>
     <ui-view id="main" class="container" id="mainContainer"></ui-view>

    GIT commit diff for Angular template

    armengabriel, 18 Августа 2014

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

    +57

    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 "TrayIcon.h"
    
    // ----------------------------------------------------------------------------
    
    TrayIcon::TrayIcon(QObject* parent) : QSystemTrayIcon(parent),
                                          INTERVAL(1000),
                                          WIDTH_ICON(30), HEIGHT_ICON(30)
    {
        currentDate = QDate(0, 0, 0);
    
        defaultIcon = QPixmap(WIDTH_ICON, HEIGHT_ICON);
        defaultIcon.fill(Qt::black);
    
        reminderIcon = QPixmap(WIDTH_ICON, HEIGHT_ICON);
        reminderIcon.fill(Qt::yellow);
    
        thousandthDayIcon = QPixmap(WIDTH_ICON, HEIGHT_ICON);
        thousandthDayIcon.fill(Qt::green);
    
        dialogBoxIsActive = false;
    
        readSettings();
    
        wasReminder = false;
        wasCongratulation = false;
        wasSetNewDate = false;
    
        slotUpdateDate();
    
        QMenu* contextMenu = new QMenu;
    
        contextMenu->addAction("Set date of birth...",
                                                 this, SLOT(slotSetDateOfBirth()));
    
        QAction* autorunAction = contextMenu->addAction("Autorun",
                                                 this, SLOT(slotSetAutorun(bool)));
        autorunAction->setCheckable(true);
        autorunAction->setChecked(autorun);
    
        contextMenu->addSeparator();
    
        contextMenu->addAction("About...", this, SLOT(slotAboutMyProgram()));
    
        contextMenu->addSeparator();
    
        contextMenu->addAction("Quit", qApp, SLOT(quit()));
    
        setContextMenu(contextMenu);
    
        QTimer* timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), SLOT(slotUpdateDate()));
        timer->start(500);
    }
    
    // ----------------------------------------------------------------------------
    
    void TrayIcon::slotUpdateDate()
    {
        if((currentDate != QDate::currentDate()) || wasSetNewDate)
        {
            currentDate = QDate::currentDate();
    
            daysToThousandthDay
                           = INTERVAL - dateOfBirth.daysTo(currentDate) % INTERVAL;
    
            wasCongratulation = false;
            wasReminder = false;
            wasSetNewDate = false;
    
            if((daysToThousandthDay != INTERVAL) && (daysToThousandthDay != 1))
            {
                setIcon(QIcon(defaultIcon));
                setToolTip("Until next thousandth day in " +
                                 QString().number(daysToThousandthDay) + " days.");
            }
            else
            {
                if(daysToThousandthDay == 1)
                {
                    if(!wasReminder)
                        reminderBeforeDay();
                }
                else
                {
                    if(!wasCongratulation)
                        congratulation();
                }
            }
        }
    }

    Описание конструктора и одного из методов класса иконки в системном трее из программы, которая должна оповещать пользователя о каждом тысячном дне его жизни. Написано на Qt.

    Полная версия:

    main: http://pastebin.com/DEKiMWdb

    хедер класса иконки трея: http://pastebin.com/rN9NwBPB
    .cpp класса иконки трея: http://pastebin.com/uuyf5uxX

    хедер класса окна ввода даты рождения: http://pastebin.com/bmfAbFwg
    .cpp класса окна ввода даты рождения: http://pastebin.com/3R8BaPFC

    darkKnight, 18 Августа 2014

    Комментарии (19)
  7. Java / Говнокод #16555

    +118

    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
    if (operator instanceof TUOperatorStacker) {
    	dump.put("operator_type", "TUOperatorStacker");
    } else if (operator instanceof TUOperatorDestacker) {
    	dump.put("operator_type", "TUOperatorDestacker");
    } else if (operator instanceof TUOperatorTargetedStacker) {
    	dump.put("operator_type", "TUOperatorTargetedStacker");
    } else if (operator instanceof TUOperatorTargetedDestacker) {
    	dump.put("operator_type", "TUOperatorTargetedDestacker");
    }
    
    
    
    <...>
    
    
    
    String typeString = (String) dump.get("operator_type");
    TUOperator operator = null;
    
    if (typeString.equals("TUOperatorStacker")) {
    	operator = new TUOperatorStacker(simElement);
    } else if (typeString.equals("TUOperatorDestacker")) {
    	operator = new TUOperatorDestacker(simElement);
    } else if (typeString.equals("TUOperatorTargetedStacker")) {
    	operator = new TUOperatorTargetedStacker(simElement);
    } else if (typeString.equals("TUOperatorTargetedDestacker")) {
    	operator = new TUOperatorTargetedDestacker(simElement);
    }

    someone, 18 Августа 2014

    Комментарии (15)
  8. JavaScript / Говнокод #16554

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (d_min < 0) {
                                // push out by normal * |d_min|
                                x = x - d_min * T[t_min];
                                y = y - d_min * T[t_min + 1];
                                y = z - d_min * T[t_min + 2];

    Сука, блядь, пиздец, два часа убил.

    makc3d, 18 Августа 2014

    Комментарии (13)
  9. Java / Говнокод #16553

    +70

    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
    *  Calculates the minimum number of bits necessary to represent the given number.  The
         *      number should be given in its unsigned form with the starting bits equal to 1 if it is
         *      signed.  Repeatedly compares number to another unsigned int called x.
         *      x is initialized to 1.  The value of x is shifted left i times until x is greater
         *      than number.  Now i is equal to the number of bits the UNSIGNED value of number needs.
         *      The signed value will need one more bit for the sign so i+1 is returned if the number
         *      is signed, and i is returned if the number is unsigned.
     * @param number the number to compute the size of
     * @param bits 1 if number is signed, 0 if unsigned
     */
        public static int minBits(int number, int bits)
        {
        int val = 1;
        for (int x = 1; val <= number && !(bits > 32); x <<= 1) 
        {
            val = val | x;
            bits++;
        }
    
        if (bits > 32)
                {
                        assert false : ("minBits " + bits + " must not exceed 32");
                }
        return bits;
    }

    Адоб, как обычно, порадовал (условие окончания цикла).
    [color=blue]https://git-wip-us.apache.org/repos/asf/flex-sdk/repo?p=flex-sdk.git;a=blob;f=modules/swfutils/src/java/flash/swf/SwfEncoder.java;h=03a100dda92989d537b00b 96033d614c73c47801;hb=HEAD#l320[/code]

    wvxvw, 17 Августа 2014

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

    +63

    1. 1
    renderer->SetBackground(.0, .0, .0); // Background color green

    Abbath, 16 Августа 2014

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