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

    +142

    1. 1
    2. 2
    3. 3
    // string errorMessage;
    if (result == false)
       result = true; //because model is not changed

    because

    sharpman, 24 Октября 2014

    Комментарии (10)
  2. VisualBasic / Говнокод #16928

    −122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Public m_Values As Hashtable    
    
    Public Function GetSensorType(p_SensorType As SensorType) As SensorValue
            For Each de As DictionaryEntry In m_Values
                If CType(de.Key, SensorType) = p_SensorType Then
                    Return de.Value
                End If
            Next
            Return Nothing
     End Function

    Отличный пример работы с Hashtable!

    IlyaS, 24 Октября 2014

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

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public new string ID
    {
    	get
    	{
    		return base.ID;
    	}
    	set
    	{
    		base.ID = value;
    	}
    }

    taburetka, 24 Октября 2014

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

    −97

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    def constant_time_compare(val1, val2):
        """
        Returns True if the two strings are equal, False otherwise.
    
        The time taken is independent of the number of characters that match.
        """
        if len(val1) != len(val2):
            return False
        result = 0
        for x, y in zip(val1, val2):
            result |= ord(x) ^ ord(y)
        return result == 0

    Django.utils.crypto в Django 1.4

    american_idiot, 24 Октября 2014

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

    −124

    1. 1
    2. 2
    <?"Объект">_и="";<?"Объект">_с=0;<?"Объект">_кол=<?"Объект">.Количество();<?"Объект">_нд=ТекущаяДата();<?"Объект">_пд=<?"Объект">_нд;
    	<?"Объект">_с=<?"Объект">_с+1;Если <?"Объект">_пд<>ТекущаяДата() Тогда <?"Объект">_пд=ТекущаяДата();<?"Объект">_ост=(<?"Объект">_пд-<?"Объект">_нд)/<?"Объект">_с*(<?"Объект">_кол-<?"Объект">_с);Состояние(<?"Объект">_и+Формат(<?"Объект">_с/<?"Объект">_кол*100,"ЧДЦ=1;")+"% "+формат('00010101'+<?"Объект">_ост,"ДФ=ЧЧ:мм:сс"));КонецЕсли;

    Шаблон для строки состояния. Видимо, первая строка вставляется перед циклом, вторая внутри.

    anacefalus, 24 Октября 2014

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

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    SqlConnection cmdConnection = GetSKDConnection();
    cmdConnection.Open();
    SqlCommand resetCardCmd = new SqlCommand("UPDATE hPerson SET CurrentCardNr=NULL WHERE PersonalNr='" + pass.Number.TrimStart('0'), cmdConnection);
    resetCardCmd.CommandText = "DELETE FROM bCardData WHERE CardFK=" + (from pf in pass.PassFieldList where pf.FieldTypeName == "radio" select pf).Single().Card.CardNumber;
    resetCardCmd.ExecuteNonQuery();

    Мне кажется, или что то важное точно не произойдет?

    SantePaulinum, 24 Октября 2014

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

    −117

    1. 1
    SET_CCC="CCC= ${CCC}"

    Где-то в макросах для autotools.

    bormand, 24 Октября 2014

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

    −93

    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
    # Source: python3.4/distutils/dir_util.py
    
    
    # cache for by mkpath() -- in addition to cheapening redundant calls,
    # eliminates redundant "creating /foo/bar/baz" messages in dry-run mode
    _path_created = {}
    
    # I don't use os.makedirs because a) it's new to Python 1.5.2, and
    # b) it blows up if the directory already exists (I want to silently
    # succeed in that case).
    def mkpath(name, mode=0777, verbose=1, dry_run=0):
        """Create a directory and any missing ancestor directories.
    
        If the directory already exists (or if 'name' is the empty string, which
        means the current directory, which of course exists), then do nothing.
        Raise DistutilsFileError if unable to create some directory along the way
        (eg. some sub-path exists, but is a file rather than a directory).
        If 'verbose' is true, print a one-line summary of each mkdir to stdout.
        Return the list of directories actually created.
        """
    
        global _path_created
    
        # Detect a common bug -- name is None
        if not isinstance(name, basestring):
            raise DistutilsInternalError, \
                  "mkpath: 'name' must be a string (got %r)" % (name,)
    
        # XXX what's the better way to handle verbosity? print as we create
        # each directory in the path (the current behaviour), or only announce
        # the creation of the whole path? (quite easy to do the latter since
        # we're not using a recursive algorithm)
    
        name = os.path.normpath(name)
        created_dirs = [] 
        if os.path.isdir(name) or name == '':
            return created_dirs
        if _path_created.get(os.path.abspath(name)):
            return created_dirs
        ...

    Мало того, что метод жив на основании того, что os.makedirs был добавлен только в Python 1.5.2 (мама родная, 2.7 скоро закопаем, а говно всё тянется), так его ещё и умудрились наиндусить на 60 строк кода, да ещё и ХХХ секцию аккуратно положили. Ладно, чего это я придираюсь... Ах да, оно кеширует уже созданные директории, так что если создать папку и удалить её, второй раз её уже никак не создашь...

    frol, 23 Октября 2014

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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    //#if UNITY_IPHONE && !(UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_3_6 || UNITY_3_7 || UNITY_3_8 || UNITY_3_9 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9)
    if (Selection.activeGameObject != null)
    control = (IControl)Selection.activeGameObject.GetComponent("IControl");
    //#endif

    принял код от юнити юниора

    sladkijBubaleh, 23 Октября 2014

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

    +153

    1. 1
    document.body.innerHTML = document.body.innerHTML.replace(/guest/g, '');<

    DesmondHume, 23 Октября 2014

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