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

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

    +157

    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
    function run()
    {
      var test = [60, 1, 5, 70, 8];
      var biggest = 100;
      var biggest_index = 0;
      for (var i = 0; i < test.length; i++)
      {
        if (test[i] < test[i + 1])
        {
          biggest = test[i + 1];
          test[biggest - [i + 1]] = [biggest];
        }
      }
      test[test.length] = biggest;
    }
    run();

    таск был найти наибольшего эллемента масива [60, 1, 5, 70, 8]; во что получилось у коллеги новобранца. это был его 20-ты опыт ;)

    apostolovd, 22 Января 2015

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

    +94

    1. 1
    MenuGame extends GameMenu

    jangolare, 19 Января 2015

    Комментарии (16)
  4. PHP / Говнокод #17365

    +148

    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
    <html>
        <head>
            <title>Тест</title>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
        </head>
        <body>
            <div align="center">
                <h1>Задание</h1>
                Написать решение c использованием ООП, которое позволяет переводить целые числа в каком-нибудь диапазоне (c миллионами включительно) в текст ( разговорный)<br>
                на трех языках (рус., англ., укр.)
            </div>
            <form action="receivenumber.php" method="post">
                <label for="textnumber">Число:</label>
                <input type="number" id="textnumber" name="textnumber" required 
                       min="-9999999" max="9999999" step="1"/><br>
                <label for="selectlanguage">Выбирите язык:</label>
                <select id="selectlanguage" name="selectlanguage">
                    <option value="eng">English</option>
                    <option value="ukr">Ukrainian</option>
                    <option value="rus" selected>Russian</option>
                </select><br>
                <input type="submit" name="submitnumber" value="Отправить"><br>
            </form>
        </body>
    </html>

    А это файл "index.html", который передает данные скрипту "receivenumber.php"

    ppd, 23 Декабря 2014

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

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    void _device_ChangeStsConnect(bool Conn)								
    {
    	switch (Conn)
    	{
    		case true: Start(); break;
    		case false: Stop(); break;
    		default: break;
    	}
    }

    "Классический" switch булевой переменной.

    Qetu107, 25 Ноября 2014

    Комментарии (16)
  6. PHP / Говнокод #17071

    +163

    1. 1
    $result = $db->query("update `" . $table_prefix . "options` set `option_value`='a:2:{i:0;b:0;s:8:" . '"auto_add"' . ";a:0:{}}' where `option_name`='nav_menu_options';");

    unserialize "глазами на лету" - ЛЕГКО!!!!

    taras_shs, 06 Ноября 2014

    Комментарии (16)
  7. JavaScript / Говнокод #16852

    +170

    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
    <form id ='activate'>
        <div class ='form-control'>
            <label>Введите код подтверждения из SMS</label>
            <input type ='text' name ='code' class ='form-control' />
        </div>
        <button class = 'btn btn-success'>Активировать</button>
    </form>
    <script>
        $(function () {
            $('#activate').submit(function () {
                if ($('#activate [name="code"]').val != '<?php echo $secretCode; ?>') {
                    alert('Вы ввели неверный код!')
                    return false;
                }
            })
        })
    </script>

    Бог безопасности

    Snickers, 15 Октября 2014

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

    −115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    ls -laF /usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0
    if [ "$?" -ne 0 ]; then
        current_location=$PWD
        gzip -dc < curl-7.22.0.tar.gz | tar -xf -
        cd curl-7.22.0
        ./configure --prefix=/usr
        make
        make install
        cd $current_location
    else
        echo "libcurl.so.4.2.0 already exist!"
    fi

    Ключ -f? Нет, не слышали.

    codemonkey, 12 Октября 2014

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

    +140

    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
    @foreach (var groupTest in Model.Select(t => t.TestType).Distinct())
    {
        <div class="form-column form-column2">
            <div class="static-height">
                <p class="content-subblock-title left upper-text">
                    <label>
                        @if (@groupTest.GetEnumDescription().Length < 34)
                        {
                            <text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>
                        }
                        @groupTest.GetEnumDescription()
                    </label>
                </p>
                @foreach (var item in Model.Where(t => t.TestType == groupTest).OrderBy(t => t.Order))
                {
                    <div class="donation-row">
                        <label>@item.TestName</label>
                        <span class="@item.TestClass blood-test-value-don">
                            @item.TestValue
                        </span>
                    </div>
                }
    
            </div>
        </div>
    }

    Я пялюсь на этот кусок вот уже полчаса...

    amatenkov, 17 Сентября 2014

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

    +125

    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
    (closer-mop:defclass virtual-metaclass (closer-mop:standard-class) ())
    
    (closer-mop:defclass virtual-slot-definition
        (closer-mop:standard-slot-definition)
      ((function :initarg :function 
                 :accessor virtual-slot-definition-function)))
    
    (defmethod slot-definition-allocation ((slotd virtual-slot-definition))
      :virtual)
    
    (defmethod (setf slot-definition-allocation) 
        (allocation (slotd virtual-slot-definition))
      (unless (eq allocation :virtual)
        (error "Cannot change the allocation of a ~S"
               'virtual-direct-slot-definition)) allocation)
    
    (closer-mop:defclass virtual-direct-slot-definition 
        (closer-mop:standard-direct-slot-definition
         virtual-slot-definition) ())
    
    (defmethod closer-mop:direct-slot-definition-class
        ((class virtual-metaclass) &rest initargs)
      ;; Use virtual-direct-slot-definition if appropriate.
      (if (eq (getf initargs :allocation) :virtual)
          (find-class 'virtual-direct-slot-definition)
          (call-next-method)))
    
    (closer-mop:defclass virtual-effective-slot-definition 
        (closer-mop:standard-effective-slot-definition
         virtual-slot-definition) ())
    
    (defmethod closer-mop:effective-slot-definition-class 
        ((class virtual-metaclass) &rest initargs)
      ;; Use virtual-effective-slot-definition if appropriate.
      (let ((slot-initargs (getf initargs :initargs)))
        (if (member :virtual-slot slot-initargs)
            (find-class 'virtual-effective-slot-definition)
            (call-next-method))))
    
    (defmethod closer-mop:compute-effective-slot-definition 
        ((class virtual-metaclass) name direct-slot-definitions)
      ;; Copy the function into the effective slot definition
      ;; if appropriate.
      (let ((effective-slotd (call-next-method)))
        (dolist (slotd direct-slot-definitions)
          (when (typep slotd 'virtual-slot-definition)
            (setf (virtual-slot-definition-function effective-slotd) 
                  (virtual-slot-definition-function slotd))
            (return)))
        effective-slotd))
    
    (defmethod closer-mop:slot-value-using-class 
        ((class virtual-metaclass) object slot-name)
      (let ((slotd (find slot-name (closer-mop:class-slots class) 
                         :key 'closer-mop:slot-definition-name)))
        (if (typep slotd 'virtual-slot-definition)
            (funcall (cadr (virtual-slot-definition-function slotd)) :get object)
            (call-next-method))))
    
    (defmethod (setf closer-mop:slot-value-using-class) 
        (value (class virtual-metaclass) object slotd)
      (if (typep slotd 'virtual-slot-definition)
          ;; This is ugly and probably not portable, but what if?
          (funcall (cadr (virtual-slot-definition-function slotd))
                   :set object value)
          (call-next-method)))
    
    (defmethod closer-mop:slot-boundp-using-class 
        ((class virtual-metaclass) object slot-name)
      (let ((slotd (find slot-name (closer-mop:class-slots class) 
                         :key 'closer-mop:slot-definition-name)))
        (if (typep slotd 'virtual-slot-definition)
            (funcall (cadr (virtual-slot-definition-function slotd)) :is-set object)
            (call-next-method))))
    
    (defmethod closer-mop:slot-makunbound-using-class 
        ((class virtual-metaclass) object slot-name)
      (let ((slotd (find slot-name (closer-mop:class-slots class) 
                         :key 'closer-mop:slot-definition-name)))
        (if (typep slotd 'virtual-slot-definition)
            (funcall (virtual-slot-definition-function slotd) :unset object)
            (call-next-method))))

    О простоте объектно-ориентированого программирования, или страшная правда, которую от вас так долго скрывали.
    Написано по мотивам: http://www.lispworks.com/documentation/lw50/LWUG/html/lwuser-173.htm В попытке сделать это, по возможности, портабельным (на SBCL вроде даже завелось).

    Я понимаю, что читать это никто не будет, поэтому, краткий пересказ событий:
    Захотелось мне виртуальных свойств, ну тоесть так, чтобы при обращении к Сипипишной библиотеке, для которой я ваяю оберкту не было различий между обычными Лисповыми объектами и Сипипишными.
    Простой вариант - скопировать значения, но перформанс же!
    И вот родился этот вариант. (Использование не показано, т.как не влезло).

    wvxvw, 12 Сентября 2014

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

    +138

    1. 1
    p.fANT = Convert.ToUInt16(((devStat & (1 << 13)) != 0 ? "1" : "0") + ((devStat & (1 << 12)) != 0 ? "1" : "0"), 2);

    Вот сижу думаю так задуманно или автор сам не понял что написал

    Smekalisty, 12 Сентября 2014

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