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

    В номинации:
    За время:
  2. Куча / Говнокод #12181

    +123

    1. 1
    val ret = method.invoke(this, args:_*)

    Превращаем Array[Any] в жабовый Object[] в Scala.

    myaut, 23 Ноября 2012

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

    +45

    1. 1
    2. 2
    if (!isset($_POST['searchText'])) $_POST['searchText'] = $_GET['searchText'];
    if (!isset($_POST['by'])) $_POST['by'] = $_GET['by'];

    Connor, 13 Ноября 2012

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

    +45

    1. 1
    2. 2
    3. 3
    $parts = preg_replace('~[^0-9a-z-/]~', '',  parse_url( $_SERVER['REQUEST_URI'] , PHP_URL_PATH ) );
    $parts = explode('/', $parts );
    $parts = array_values( array_filter( $parts, function( $var ){ return !empty( $var ); } ) );

    функциональность пхп развращает
    вместо array_filter с callback-ом можно было обработать строку trim($parts, '/');
    если уж array_filter, то в данном случае прокатит и array_filter( $parts, 'strlen' );
    это хотя бы не потребует обновления до версии 5.3

    shitcoder, 09 Ноября 2012

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

    −122

    1. 1
    2. 2
    if (activeObject && (((activeObject is LevelObjectBirdBlack) || (activeObject is LevelObjectBirdOrange)) || (activeObject is LevelObjectBirdOrange)) && (!(activeObject as LevelObjectBird).specialPowerUsed || activeObject.getSpecialAnimationProgress() >= 0 ) )
    {...}

    primerno tak vyglyadit angry birds from inside

    iliakot, 29 Октября 2012

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

    +154

    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
    this.draw = function(scale) {
      ctx.save();
      ctx.translate(this.posX, this.posY);
      if (this.scale && this.scale < 1) ctx.scale(this.scale, this.scale);
      if (scale > 0) { 
        var boxHeight = 124.678568 + 0.394292; // ?!
        ctx.translate(0, ((boxHeight)-(scale*(boxHeight))));
        ctx.scale(scale,scale);
      }
      // вырезанный говнокод, отрисовывающий бабл в обычном масштабе
    
      ctx.restore();
    }

    Отрисовка нескольких фигур а-ля "бабл" на canvas с анимацией "выростания" бабла из своего нижнего левого угла. В метод draw передается параметр scale, содержащий значение масштаба фигуры в текущем кадре. /facepalm

    nbspjr, 05 Октября 2012

    Комментарии (1)
  7. SQL / Говнокод #11854

    −121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    SELECT ISNULL(SUM(1), 0) 
     FROM Stat_DailySnapshotPurchases
     WHERE 1=1
      AND ForDate BETWEEN '2012-08-01' AND '2012-09-14'
      AND ItemType = 4

    Оригинальный способ подсчета количества строк

    leon_mz, 01 Октября 2012

    Комментарии (1)
  8. Куча / Говнокод #11787

    +127

    1. 1
    override def text: String = super.text

    https://github.com/scala/scala/blob/master/src/library/scala/xml/Node.scala

    rat4, 17 Сентября 2012

    Комментарии (1)
  9. PHP / Говнокод #11751

    +58

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function abs_url_text ($text, $base_url) {
       define(BASE_URL, $base_url); 
    ...
    ... BASE_URL . "\"";
    
    }

    Реально серьёзный подход.
    Садо-мазо!

    virtual_cia, 11 Сентября 2012

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

    −95

    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
    - (void)awakeFromNib
    { 
        // ...
        [[_contextMenu itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem1Caption", nil)];
        [[_contextMenu itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem2Caption", nil)];
        [[_contextMenu itemAtIndex:2] setTitle:NSLocalizedString(@"ContextMenuItem3Caption", nil)];
        [[_contextMenu itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem4Caption", nil)];
        [[_contextMenu itemAtIndex:4] setTitle:NSLocalizedString(@"ContextMenuItem5Caption", nil)];
        [[_contextMenu itemAtIndex:5] setTitle:NSLocalizedString(@"ContextMenuItem6Caption", nil)];
        [[_contextMenu itemAtIndex:6] setTitle:NSLocalizedString(@"ContextMenuItem7Caption", nil)];
        [[_contextMenu itemAtIndex:8] setTitle:NSLocalizedString(@"ContextMenuItem8Caption", nil)];
        [[_contextMenu itemAtIndex:10] setTitle:NSLocalizedString(@"ContextMenuItem9Caption", nil)];
        [[_contextMenu itemAtIndex:11] setTitle:NSLocalizedString(@"ContextMenuItem10Caption", nil)];
        [[_contextMenu itemAtIndex:13] setTitle:NSLocalizedString(@"ContextMenuItem11Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem11-1Caption", nil)];         // submenu notices
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem11-2Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:2] setTitle:NSLocalizedString(@"ContextMenuItem11-3Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem11-4Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:4] setTitle:NSLocalizedString(@"ContextMenuItem11-5Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:5] setTitle:NSLocalizedString(@"ContextMenuItem11-6Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:6] setTitle:NSLocalizedString(@"ContextMenuItem11-7Caption", nil)];
        [[[[_contextMenu itemAtIndex:13] submenu] itemAtIndex:7] setTitle:NSLocalizedString(@"ContextMenuItem11-8Caption", nil)];
        [[_contextMenu itemAtIndex:14] setTitle:NSLocalizedString(@"ContextMenuItem12Caption", nil)];
        [[[[_contextMenu itemAtIndex:14] submenu] itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem12-1Caption", nil)];
        [[[[_contextMenu itemAtIndex:14] submenu] itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem12-2Caption", nil)];
        [[[[_contextMenu itemAtIndex:14] submenu] itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem12-3Caption", nil)];
        [[_contextMenu itemAtIndex:16] setTitle:NSLocalizedString(@"ContextMenuItem13Caption", nil)];
        [[_contextMenu itemAtIndex:17] setTitle:NSLocalizedString(@"ContextMenuItem14Caption", nil)];
        [[_contextMenu itemAtIndex:18] setTitle:NSLocalizedString(@"ContextMenuItem15Caption", nil)];
        [[_contextMenu itemAtIndex:19] setTitle:NSLocalizedString(@"ContextMenuItem16Caption", nil)];
        [[_contextMenu itemAtIndex:20] setTitle:NSLocalizedString(@"ContextMenuItem17Caption", nil)];
        [[_contextMenu itemAtIndex:21] setTitle:NSLocalizedString(@"ContextMenuItem18Caption", nil)];
        
        [[_contextMenu2 itemAtIndex:0] setTitle:NSLocalizedString(@"ContextMenuItem1", nil)];
        [[_contextMenu2 itemAtIndex:1] setTitle:NSLocalizedString(@"ContextMenuItem2", nil)];
        [[_contextMenu2 itemAtIndex:3] setTitle:NSLocalizedString(@"ContextMenuItem3", nil)];
        [[_contextMenu2 itemAtIndex:4] setTitle:NSLocalizedString(@"ContextMenuItem4", nil)];
        [[_contextMenu2 itemAtIndex:5] setTitle:NSLocalizedString(@"ContextMenuItem5", nil)];
        [[_contextMenu2 itemAtIndex:7] setTitle:NSLocalizedString(@"ContextMenuItem6", nil)];
        [[_contextMenu2 itemAtIndex:8] setTitle:NSLocalizedString(@"ContextMenuItem7", nil)];
        // ...
    }

    Метод локализации пунктов меню.
    Весьма оригинальный.

    glook, 03 Сентября 2012

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

    +57

    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
    <?php
    //...
    foreach ($month as $key=>$value)
    	{
    		if($value!=0)
    		{
    			$leased[$year[$key]] = $pay_leased->get_leased_pay($year[$key],$value);
    			$dialup[$year[$key]] = $pay_dialup->get_billing_pay($year[$key],$value);
    			$domain[$year[$key]] = $pay_domain->get_domain_pay($year[$key],$value);
    			$web[$year[$key]] = $pay_web->get_hosting_pay($year[$key],$value);
    
    			for ($d=1;$d<=31;$d++) // во всех месяцах по 31 дню, да
    			{
    				$leased[$year[$key]][$value][$d] = isset($leased[$year[$key]][$value][$d]) ? $leased[$year[$key]][$value][$d] : 0;
    				$dialup[$year[$key]][$value][$d] = isset($dialup[$year[$key]][$value][$d]) ? $dialup[$year[$key]][$value][$d] : 0;
    				$domain[$year[$key]][$value][$d] = isset($domain[$year[$key]][$value][$d]) ? $domain[$year[$key]][$value][$d] : 0;
    				$web[$year[$key]][$value][$d] = isset($web[$year[$key]][$value][$d]) ? $web[$year[$key]][$value][$d] : 0;
    			}
    			ksort($leased[$year[$key]][$value]);
    			ksort($dialup[$year[$key]][$value]);
    			ksort($domain[$year[$key]][$value]);
    			ksort($web[$year[$key]][$value]);
    
    			for ($c=1;$c<=31;$c++) // и еще
    			{
    				$leased[$year[$key]][$value][$c] = $leased[$year[$key]][$value][$c-1]+$leased[$year[$key]][$value][$c];
    				$dialup[$year[$key]][$value][$c] = $dialup[$year[$key]][$value][$c-1]+$dialup[$year[$key]][$value][$c];
    				$domain[$year[$key]][$value][$c] = $domain[$year[$key]][$value][$c-1]+$domain[$year[$key]][$value][$c];
    				$web[$year[$key]][$value][$c] = $web[$year[$key]][$value][$c-1]+$web[$year[$key]][$value][$c];
    				$sum[$year[$key]][$value][$c] = $leased[$year[$key]][$value][$c]+$dialup[$year[$key]][$value][$c]+$domain[$year[$key]][$value][$c]+$web[$year[$key]][$value][$c]; // вау, какая большая строка
    			}
    		}
    	}
    //...

    Досталось в подарок от предыдущих разработчиков. Наверное, я хреновый программист, если ничего не могу здесь понять...
    Комментарии мои, исходник вообще лишен комментариев.

    rsvasilyev, 28 Августа 2012

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