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

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

    +137

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public static ListBox GetListBox()
    {
        var list = _customList as ListBox;
    
        if (list != null)
        {
            return list;
        }
    
        return null;
    }

    Наверное это бояный пример говнокода, но все же я скопировал его собственными руками

    Smekalisty, 27 Сентября 2013

    Комментарии (40)
  3. Pascal / Говнокод #13652

    +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
    begin
    if(TimerVremya.Enabled = True) then
      begin
        if(CheckBox1.Checked = False) then
        begin
        Bass_channelPlay(Channel, false);
        Panel1.Caption := 'Playing';
        TimerFraza.Enabled := False;
        end
        else
        begin
         Bass_channelPlay(Privlek, false);
         Timer2.Enabled := True;
         TimerFraza.Enabled := False;
        end;
    end;

    А не ударить ли нам по басам? Вот только запашок не к месту, с чего бы такая оказия?..

    Stertor, 23 Августа 2013

    Комментарии (40)
  4. JavaScript / Говнокод #13602

    +152

    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
    if (!jQuery('#email').attr('value')){
                jQuery('#email').css('border', '1px solid red');
                jQuery('div.errors').append('<p>Не указан "E-Mail"</p>');
                error=true;
            }
            else{
                email=jQuery('#email').attr('value');
                if ((email.length<8) || (email.search(/[а-яёЁ,~><|\/*#№`!"'$:;%^&?)(_=+]/i)+1) || (email.indexOf(' ')+1) || (email.indexOf('--')+1) || (email.indexOf('-.')+1) || (email.indexOf('.-')+1) || (email.indexOf('\\')+1) || (email.indexOf('..')+1) || (email.indexOf('.')==0) || (email.indexOf('-')==0) || (email.indexOf('@')==0) || (!(email.indexOf('@')+1)) || ((email.indexOf('@')!=email.lastIndexOf('@')) && (email.lastIndexOf('@')+1)) || (email.indexOf('@')>email.lastIndexOf('.')) || (!(email.lastIndexOf('.')<(email.length-2)))){
                    jQuery('#email').css('border', '1px solid red');
                    jQuery('div.errors').append('<p>E-mail указан некорректно</p>');
                    error=true;
                }
                else jQuery('#email').attr('style', null);
            }

    Функция проверки Email на валидность.

    Regexp для слабых.

    Cherrionella, 13 Августа 2013

    Комментарии (40)
  5. JavaScript / Говнокод #13506

    +147

    1. 1
    2. 2
    3. 3
    $(".rating").each(function() { 
    $(this).find('input').hide(); 
    });

    Самое интересное, что в блоке .rating никогда нет и не было input

    yamaha252, 29 Июля 2013

    Комментарии (40)
  6. Pascal / Говнокод #13316

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // Delpih 7 отказывается компилировать этот код, тогда как в Delphi 2010 он вполне успешно компилируется.
    // Отчего это?
    
    for pthread in lst do
    ...
    
    >>[Error] Unit1.pas(89): Operator not applicable to this operand type

    Stertor, 06 Июля 2013

    Комментарии (40)
  7. ActionScript / Говнокод #13129

    −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
    public function set flip(value:Boolean):void {
        if (this.object.flip != value) {
            this.object.flip = value;
            this.clearCells();
            var cell:Cell = this.cell;
        }
    }
    
    public function get cell():Cell {
        if (!this._cell) {
            createCell();
        }
        return this._cell;
    }

    Ненавижу подергивание.

    kyzi007, 07 Июня 2013

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

    −80

    1. 1
    Если Найти(Строка(ТипЗнч(Ссылка)),"Документ") Тогда

    Проверка, является ли переданная ссылка документом. Сегодня без авторства.

    ilya2184, 05 Июня 2013

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

    +129

    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
    public static MvcHtmlString TextWithLinks(this HtmlHelper helper, string inputStr)
    {
      string html = String.Empty;
      Uri url;
      string[] arr = inputStr.Split(' ');
      for (int i = 0; i < arr.Length; i++)
      {
        if (i != 0)
        {
          html += " ";
        }
        if (Uri.TryCreate(arr[i],UriKind.Absolute, out url))
        {
          html += String.Format("<a href='{0}' target='_blank'>{0}</a>", url.AbsoluteUri);
        }else
        {
          html += arr[i];
        }
      }
      return new MvcHtmlString(html);
    }

    DarkThinker, 30 Мая 2013

    Комментарии (40)
  10. Haskell / Говнокод #12262

    −85

    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
    by :: Int -> [a] -> [[a]]
    by _ [] = []
    by n xs = take n xs: by n (drop n xs)
     
    words2 :: String -> (String, String)
    words2 str = conc $ words str where
        conc (x:xs) = (x, concat xs)
     
    groupTemplates :: String -> [(String, String)]
    groupTemplates xs = map (words2) (lines xs)
     
    decodeOne :: String -> [(String, String)] -> String
    decodeOne _ [] = ""
    decodeOne str (x:xs) | str == fst x = fst x ++ " " ++ snd x ++ "\n"
    decodeOne str (_:xs) = decodeOne str xs
     
    decode :: [String] -> [(String, String)] -> String
    decode bs ts = concat $ map (\b -> decodeOne b ts) bs
     
    main = do
        bits      <- readFile "bits.txt"
        templates <- readFile "templates.txt"
     
        writeFile "out.txt" $ decode (by 4 bits) (groupTemplates templates)

    http://www.cyberforum.ru/haskell/thread723767.html

    Fai, 09 Декабря 2012

    Комментарии (40)
  11. PHP / Говнокод #12158

    +46

    1. 1
    for($i=0;$i<=100;$i++)echo(!$i?$i:($i%3==0&&$i%5==0?'FizzBuzz':($i%3==0?'Fizz':($i%5==0?'Buzz':$i)))).'<br>';

    FizzBuzz - мое решение.

    pkot, 20 Ноября 2012

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