1. Java / Говнокод #12140

    +83

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ((decoded.length() > 40) && (el != null))
          el.addMsg("Info: Decoded More Characters Than Is Specified By The Track 2 ANSI/ISO Standards");
        else if ((decoded.length() > 107) && (el != null)) {
          el.addMsg("Info: Decoded More Characters Than Is Specified By The Track 3 ANSI/ISO Standards");
        }

    Декодинг содержимого магнитной полосы карты в софте одного банка.

    popoffka, 17 Ноября 2012

    Комментарии (9)
  2. JavaScript / Говнокод #12139

    +158

    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
    if (
        event.which == $.ui.keyCode.COMMA ||
        event.which == $.ui.keyCode.ENTER ||
        (
            event.which == $.ui.keyCode.TAB &&
            that._tagInput.val() !== ''
        ) ||
        (
            event.which == $.ui.keyCode.SPACE &&
            that.options.allowSpaces !== true &&
            (
                $.trim(that._tagInput.val()).replace( /^s*/, '' ).charAt(0) != '"' ||
                (
                    $.trim(that._tagInput.val()).charAt(0) == '"' &&
                    $.trim(that._tagInput.val()).charAt($.trim(that._tagInput.val()).length - 1) == '"' &&
                    $.trim(that._tagInput.val()).length - 1 !== 0
                )
            )
        )
    ) {
        event.preventDefault();
        that.createTag(that._cleanedInput());
    
        // The autocomplete doesn't close automatically when TAB is pressed.
        // So let's ensure that it closes.
        that._tagInput.autocomplete('close');
    }

    https://github.com/aehlke/tag-it/blob/master/js/tag-it.js#L183

    Sc0rp10, 16 Ноября 2012

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

    +14

    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
    [code=cpp]
    #include <iostream>
    #include <cmath>
    
    void foo(double x, double y)
    {
        if (std::cos(x) != std::cos(y)) 
            std::cout << "Я знаю точно невозможное возможно";
    }
    
    int main()
    {
        foo(1.0, 1.0);
        return 0;
    }
    [/code]

    floatы и нуб.

    igumnovf, 16 Ноября 2012

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

    −112

    1. 1
    while h == h

    Делал так раньше, когда не знал про while True

    lancerok, 16 Ноября 2012

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

    +136

    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
    private BusinessSocialProfile GetSocialProfileLink(string searchProvider, string searchKey)
    {
    	var link = new BusinessSocialProfile { Name = searchProvider, Url = "#" };
    	
    	if (searchProvider.Contains("city", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = cityLink;
    		link.Logo = "/citysearch.png";
    		link.ImageStyle = "margin-top:-8px";
    	}
    	else if (searchProvider.Contains("google", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = googleLink;
    		link.Logo = "/google.png";
    	}
    	else if (searchProvider.Contains("yelp", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = yelpLink;
    		link.Logo = "/yelp.png";
    		link.ImageStyle = "margin-top:-8px";
    	}
    	else if (searchProvider.Contains("manta", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = mantaLink;
    		link.Logo = "/manta.png";
    	}
    	else if (searchProvider.Contains("patch", StringComparison.InvariantCultureIgnoreCase))
    	{
    		link.Url = patchLink;
    		link.Logo = "/patch.png";
    	}
    	else
    	{
    		link.Url = "#";
    		link.Logo = string.Empty;
    		link.Name = string.Empty;
    	}
    
    	return link;
    }

    уже до боли известный девелопер ;) а для чего еще нужна бизнесс-логика...?

    mangyst, 16 Ноября 2012

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

    +141

    1. 1
    C:\>php -r "echo mb_convert_encoding('хуй', 'cp866', 'windows-1251') . chr(7);"

    __proto__, 15 Ноября 2012

    Комментарии (15)
  7. Си / Говнокод #12133

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #define LengthOfArrayInternal(a)(sizeof(a)/sizeof(a[0]))
     
    #define is_array(x) _Generic((x), typeof((x)[0])[LengthOfArrayInternal(x)]:1, default: 0)
     
    #define COMPILE_TIME_ASSERT(expr) char constraint[expr]
     
    #define length_of_array(a) ({COMPILE_TIME_ASSERT(is_array(a)); LengthOfArrayInternal(a)})

    Определение длины массива. gcc и с11 only.
    Говно как известно рождается в споре:
    http://govnokod.ru/12108#comment160631

    LispGovno, 15 Ноября 2012

    Комментарии (48)
  8. Assembler / Говнокод #12132

    +109

    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
    GLOBAL _start
        SEGMENT .text
    _start:
         mov eax,4 ; N function=write
         mov ebx,1 ; N handle=1 (stdout)
         mov ecx, txt ; address of buf
         mov edx,16 ; number of byte
         int 80h
    
         mov eax,3 ; N function=read
         mov ebx,0 ; 0 handle=0 (stdin)
         mov ecx, buf ; address of buf
         mov edx,80 ; number of byte
         int 80h
    
         mov [len],eax ;save length buf
         mov byte [buf+1],'!'
    
         mov eax,4 ; N function=write
         mov ebx,1 ; N handle=1 (stdout)
         mov ecx, buf ; address of buf
         mov edx,[len] ; number of byte
         int 80h
    
         mov eax,1 ; function=exit
         int 80h 
         
    SEGMENT .data
    	buf times 80 db 0 ;
    	len dd 0
    	txt db 'Enter the text '

    dos_, 15 Ноября 2012

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

    +62

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    _L1:
            if(i$ >= len$)
                break MISSING_BLOCK_LABEL_133;
            Constructor constructor = arr$[i$];
            if(Objects.equals(pattern, constructor.getParameterTypes()))
                return instantiateByConstructor(constructor, params);
            i$++;
              goto _L1
            return instantiateByClass(clazz);
            Exception e;
            e;
            Exception cause = e;

    TopS BI и где вы только находите таких программистов.......

    mrFoxs, 15 Ноября 2012

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

    +18

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    using namespace boost;
    typedef filesystem::recursive_directory_iterator dir_iter_t;
    dir_iter_t itt(filesystem::current_path());
    while ([&](dir_iter_t &itter) -> decltype(itter)
    {
        std::cout << boost::filesystem::path((*itter++).path()).make_preferred().string() << std::endl;
        return itter;
    }(itt) != dir_iter_t());

    Вчера ночью написал сие чудо , сегодня когда увидел - меня чуть приступ не хватил.
    Выводит в консоль всё содержимое текущего каталога и всех вложенных.

    suc-daniil, 15 Ноября 2012

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