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

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

    +156

    1. 1
    2. 2
    $WeightF=floor($Weight);
    if ($WeightF<$Weight) {$WeightF=$WeightF+1;}

    ненуачо, ceil же для слабаков

    CRRaD, 28 Октября 2011

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

    +161

    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
    function shwt($pid,$dir) {
            global $tree,$ITEM,$counts,$hasprods;
            if(!isset($tree[$pid])) return array("",0);
            $list="";
            $sum=0;
            foreach($tree[$pid] as $k=>$v) {
                    $v["hasprods"]=(isset($hasprods[$k])? "1":"");
                    $v["dir"]=$dir.$v["dir"]."/";
                    $x=shwt($k,$v["dir"]);
                    if(isset($counts[$k])) $v["cnt"]=$counts[$k];else $v["cnt"]=0;
                    $v["cnt"]+=$x[1];
                    $sum+=$v["cnt"];
                    $v["sub"]=$x[0];
                    $v["open"]=(strpos(" ".$_SERVER["REQUEST_URI"],$v["dir"])==1? 1:"");
                    $list.=sendAr2blk($v,$ITEM);
            }
            return array($list,$sum);
        }

    ф-я построения каталога меню в самописной CMS

    alex1, 28 Октября 2011

    Комментарии (5)
  4. VisualBasic / Говнокод #8319

    −148

    1. 1
    2. 2
    Begin Brahman
    О чем молчат брахманы

    Брехем.

    alexoy, 27 Октября 2011

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

    −128

    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
    // Abstract Class for an HTTP Request
    package com.somecompany
    {
    	public class HTTPServiceBase
    	{
        	private static const ERROR:String = "ERROR";
        	private static const COMPLETE:String = "COMPLETE";
        	
        	public function HTTPServiceBase()
        	{
        	}
    
        	private function load():void 
        	{
        		// placeholder
    		}
      	}
    }
    
    
    
    // Implementation Class for a specific HTTP Request
    package com.somecompany
    {
    	public class SpecificHTTPService extends HTTPServiceBase
    	{
    		public function SpecificHTTPService()
    		{
    			
    		}
    	}
    }

    Ищем сейчас флекс программиста. Даем им сделать тест, на дому, одной из задач было.

    Сделать запрос на сервер, это должно было быть реализованно след образом.
    + Абстрактный класс который реализует функциональность простого http get запроса (можно было использовать и URLLoader и HTTPService и HTTPMultiService)
    + Класс наследник абстрактного, формирующий конкретный запрос.

    Довольно просто, впринципе. Был тут недавно один товарисчь.
    Как написанно в резюме: Adobe FLEX, FLASH, Action Script 2.0/3.0

    И то что получили через пару дней.

    avixyu, 26 Октября 2011

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

    +157

    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
    <style>
    
    div.adsPayments a {
    
            border: 0px none;
    
            text-decoration: none;
    
    }
    
    div.adsPayments a img {
    
            border: 0px none;
    
            margin: 1px;
    
    }
    
    </style>
    
    <?
    
    echo '<style>';
    
    echo 'table td { padding: 3px 10px 3px 20px; }';
    
    echo 'html, body {font-family: helvetica; font-size: 12px;}';
    
    echo 'a, a:hover {text-decoration: none;cursor: pointer;}';
    
    echo 'td, td b { font-size: 12px; }';
    
    echo '</style>';
    
    ?>
    
    <div class="adsPayments">...

    Видимо css внутри php гораздо более внушительно смотрится..

    antongorodezkiy, 26 Октября 2011

    Комментарии (5)
  7. Ruby / Говнокод #8269

    −99

    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
    # Work fine only on call with has_many association
    def self.new_from_params options
      new_rule = Rule.new
      return nil if new_rule.project_id.nil?
    
      rule = Rule.find_by_id options[:rule_id]
      if rule.nil? or (new_rule.project.id != rule.project.id)
        rule = Rule.new
      end
    
      new_rule.rule_id = options[:rule_id]
      new_rule.users = (rule.users.to_a + options[:users].to_a).uniq
      new_rule.statuses = (rule.statuses.to_a + options[:statuses].to_a).uniq
      new_rule.tags = (rule.tags.to_a + options[:tags].to_a).uniq
      new_rule.grouped_by = options[:grouped_by].presence || rule.grouped_by.presence
      new_rule.sorted_by = options[:sorted_by].presence || rule.sorted_by.presence
      new_rule.search = options[:search].presence || rule.search.presence
      new_rule.period_start = options[:period_start].presence || rule.period_start.presence
      new_rule.period_end = options[:period_end].presence || rule.period_end.presence
    
      new_rule
     end

    emerald, 21 Октября 2011

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

    −115

    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
    SELECT product.entity_id as pid, 
           vTitle.value as title, vLength.value as length, vWidth.value as width, vHeight.value as height, vWeight.value as weight, vCapacity.value as capacity, vImg.value as img,
           tShort.value as short, tText.value as text,
           dPrice.value as price,
           cParent.category_id as parent
    FROM catalog_product_entity as product
    LEFT JOIN catalog_product_entity_varchar as vTitle ON vTitle.entity_id=product.entity_id AND vTitle.attribute_id=60
    LEFT JOIN catalog_product_entity_varchar as vLength ON vLength.entity_id=product.entity_id AND vLength.attribute_id=122
    LEFT JOIN catalog_product_entity_varchar as vWidth ON vWidth.entity_id=product.entity_id AND vWidth.attribute_id=123
    LEFT JOIN catalog_product_entity_varchar as vHeight ON vHeight.entity_id=product.entity_id AND vHeight.attribute_id=124
    LEFT JOIN catalog_product_entity_varchar as vWeight ON vWeight.entity_id=product.entity_id AND vWeight.attribute_id=69
    LEFT JOIN catalog_product_entity_varchar as vCapacity ON vCapacity.entity_id=product.entity_id AND vCapacity.attribute_id=125
    LEFT JOIN catalog_product_entity_varchar as vImg ON vImg.entity_id=product.entity_id AND vImg.attribute_id=74
    LEFT JOIN catalog_product_entity_text as tShort ON tShort.entity_id=product.entity_id AND tShort.attribute_id=62
    LEFT JOIN catalog_product_entity_text as tText ON tText.entity_id=product.entity_id AND tText.attribute_id=61
    LEFT JOIN catalog_product_entity_decimal as dPrice ON dPrice.entity_id=product.entity_id AND dPrice.attribute_id=64
    LEFT JOIN (SELECT c.category_id, c.product_id FROM catalog_category_product as c ORDER BY c.category_id DESC) as cParent ON cParent.product_id=product.entity_id
    GROUP BY cParent.product_id ORDER BY cParent.product_id

    Мой говнокод-неговнокод по экспорту товара из Magento в нашу CMS

    Android991, 17 Октября 2011

    Комментарии (5)
  9. Ruby / Говнокод #8214

    −147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    {if $oUserProfile->getProfileIcq()}
    	<strong>{$aLang.profile_social_contacts}</strong>
    	<ul>
    	{if $oUserProfile->getProfileIcq()}
    		<li class="icq"><a href="http://www.icq.com/people/about_me.php?uin={$oUserProfile->getProfileIcq()|escape:'html'}" target="_blank">{$oUserProfile->getProfileIcq()}</a></li>
    	{/if}					
    	</ul>
    {/if}

    Smarty-шаблон. ActionProfile/sidebar.tpl (17-я строчка в скине "new") из LiveStreet.
    Озадачивают 1-я и 4-я строки. Типа: "А вдруг?!"

    alexoy, 17 Октября 2011

    Комментарии (5)
  10. SQL / Говнокод #8193

    −110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    UPDATE ... 
    SET ...
    WHERE ...
         AND NVL(fndr_constraint,'ABC')=NVL('','ABC')
    ...

    Oracle 10.2 продакшн код.
    Это прям какое-то нездоровое влечение к NVL...

    slbsomeone, 14 Октября 2011

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

    −117

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /*Ахтунг! Содержит бубен*/
    		public function ToDown():void
    		{
    			while (!downCollisionTest(figure))
    			{
    				figure.position.y++;
    			}
    			RedrawFigure();
    			
    			setTimeout(function():void{Down();}, 5);
    		}

    KirAmp, 13 Октября 2011

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