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

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

    +149

    1. 1
    2. 2
    jQuery('.navbar .nav li').eq(1).addClass('dropdown').children('a').addClass('dropdown-toggle');
    jQuery('.navbar .nav li').eq(2).append("<ul class='dropdown-menu unstyled'><li><a href='/production/xx/'>оборудование</a></li>

    Добавить новый пункт меню - не вопрос...

    oxser, 30 Апреля 2013

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

    +78

    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
    {$ifdef Profile}
      {$define __TRACE__:= try Profile_TraceCall}
      {$define __END__:=finally Profile_LeaveCall; end;}
    {$else}
      {$define __TRACE__:= //}
      {$define __END__:=}
    {$endif}
    
    procedure Foo();
    begin
      __TRACE__('Foo');
      ...
      __END__
    end;

    FPC.

    runewalsh, 28 Апреля 2013

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    switch($k) {
    	default: { // Вот так поворот О_о, пацаны, я сам в шоке!
    		$ret->$k = $v;
    	}
    }

    снова мое.

    Serabas, 16 Апреля 2013

    Комментарии (2)
  5. PHP / Говнокод #12883

    +149

    1. 1
    2. 2
    3. 3
    // Hack - blacklist
    if ($msg->abonent == '12345678910')
        die("Database error");

    Найдено в крупном и сложном проекте, посреди часто вызываемого кода - проверка на забаненный номер (номер изменён).

    neTpyceB, 11 Апреля 2013

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function calculateRow(element) {
                var qty = element.val();
                var price = element.parent().next().next().children().text();
                var total = (qty * price).toFixed(2);
                $(element).parent().next().next().next().children().first().text(total);
            }

    _vinka, 09 Апреля 2013

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

    +78

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #include <unistd.h>
     
     int main()
     {
       while(1)
         fork();
     }

    wlad1994, 06 Апреля 2013

    Комментарии (2)
  8. ActionScript / Говнокод #12837

    −88

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /**
     * Indicates whether the animation is playing
     */
    public function get isPlaying():Boolean
    {
    	if(_isPlaying)
    	{
    		return _loop >= 0 || _currentTime < _totalTime && !_isPlaying;
    	}
    	return false;
    }

    DragonBones, dragonBones.animation.Animations.as : 79-86

    slavara, 01 Апреля 2013

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

    +128

    1. 1
    2. 2
    Проклятые клоуны локализуют вручную компоненты DevExpress:
    фразы типа "No available data"/"No image data" отображается везде в элементах как "Пустая дата".

    Шта вы гаварите? Гаварите громчи, я вас ни панимать!

    grobotron, 28 Марта 2013

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    $targetFolder = 'uploads/'; // Relative to the root
    // ...
    $targetPath = dirname(__FILE__) . '/' . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['file']['name'];

    "Непостоянство слеша", Pedro Molina, 2013. Холст, масло
    https://github.com/pekebyte/pekeUpload/blob/940cf27e5fef5038e2e414c72be6e34d68f2881d/upload.php

    scriptin, 24 Марта 2013

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

    −116

    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
    { 
        NSString *xContent = myTextView.text;
        
        //temp file filename
        NSString *tmpFileName = @"test1.html";
        
        //temp dir
        NSString *tempDir = NSTemporaryDirectory();
        NSLog(@"tempDirectory: %@",tempDir);
        
        //create NSURL
        NSString *path4 = [tempDir stringByAppendingPathComponent:tmpFileName];
        NSURL* url = [NSURL fileURLWithPath:path4]; 
        
        //setup HTML file contents
        NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MathJax" ofType:@"js" inDirectory:@"mathjax-MathJax-v2.0"];
        NSLog(@"filePath = %@",filePath);
        
        //write to temp file "tempDir/tmpFileName", set MathJax JavaScript to use "filePath" as directory, add "xContent" as content of HTML file
        [self writeStringToFile:tempDir fileName:tmpFileName pathName:filePath content:xContent];
        
        NSURLRequest* req = [[NSURLRequest alloc] initWithURL:url]; 
        
        //original request to show MathJax stuffs
        [myWebView loadRequest:req];
    }
    
     -(void)writeStringToFile:(NSString *)dir fileName:(NSString *)strFileName pathName:(NSString *)strPath content:(NSString *)strContent{
        
        NSString *path = [dir stringByAppendingPathComponent:strFileName];
        
        NSString *foo0 = @"<html><head><meta name='viewport' content='initial-scale=1.0' />"
    "<script type='text/javascript' src='";
        
        NSString *foo1 = @"?config=TeX-AMS-MML_HTMLorMML-full'></script>"
        "</head>"
        "<body>";
        NSString *foo2 = @"</body></html>";
        NSString *fooFinal = [NSString stringWithFormat:@"%@%@%@%@%@",foo0,strPath,foo1,strContent,foo2];
        
        [fooFinal writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
    }

    http://new2objectivec.blogspot.com/2012/03/tutorial-how-to-setup-mathjax-locally.html

    Здорово, правда?

    UncleAli, 23 Марта 2013

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