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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. Куча / Говнокод #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)
  5. 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)
  6. Java / Говнокод #16676

    +75

    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
    package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl;
    
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory;
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.EnterpriseGradeFizzBuzzSolutionStrategyFactory;
    import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy;
    
    public class FizzBuzz {
    	public void fizzBuzz(int nFizzBuzzUpperLimit) {
    		final FizzBuzzSolutionStrategyFactory mySolutionStrategyFactory =
    			new EnterpriseGradeFizzBuzzSolutionStrategyFactory();
    		final FizzBuzzSolutionStrategy mySolutionStrategy =
    			mySolutionStrategyFactory.createFizzBuzzSolutionStrategy();
    		mySolutionStrategy.runSolution(nFizzBuzzUpperLimit);
    	}
    }

    FizzBuzz Enterprise Edition на Java от уважаемых разработчиков.

    http://habrahabr.ru/company/abbyy/blog/173885/
    https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

    gost, 10 Сентября 2014

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

    +134

    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
    public static class GlobalFunc
    {
    	// bla-bla-bla ...
     
    	public static bool isDouble(string input)
    	{
    		Double dec;
    		return Double.TryParse(input, out dec);
    	}
    
    	public static bool isUShort(string input)
    	{
    		ushort dec;
    		return ushort.TryParse(input, out dec);
    	}
    
    	public static bool isShort(string input)
    	{
    		short dec;
    		return short.TryParse(input, out dec);
    	}
    
    	public static bool IsDate(string input)
    	{
    		DateTime date;
    		return DateTime.TryParse(input, out date);
    	}
    }

    face palm

    Smekalisty, 26 Августа 2014

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private Boolean active = false;
    ...
    synchronized (active) {
    ...
    }

    Чудо синхронизации. Блокируется раз и навсегда.

    borka, 25 Августа 2014

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

    −405

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    CGFloat ageInYears = self.user.age;
                 
    if (ageInYears < 1) {
        CGFloat ageInSeconds = [[NSDate date] timeIntervalSinceDate:self.user.birthday];
        ageInYears = floorf(ageInSeconds / (365.25 * 24.0 * 60.0 * 60.0));
    }
    
    // ...
    
    profileInfoCell.schoolLabel.text = [NSString stringWithFormat:@"%.0f", ageInYears];

    нет слов

    realsugar, 30 Июля 2014

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

    +160

    1. 1
    if ($sess_gr != 7 || $sess_gr == 4 || $sess_gr == 14 || $sess_gr == 15) { // ... }

    Избыточное условие.

    Khvorostin, 28 Июля 2014

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

    +160

    1. 1
    2. 2
    3. 3
    if (a % 1 == 0) {
        // a - целое число
    }

    Вот такая вот проверка.

    bormand, 14 Июля 2014

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