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

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

    +125

    1. 1
    'q<->5.,q<->r<0>3.,q<T>r<0>3.,q<:>r<0>3.,q<:>r<0>3.,r<0>2.' 8!:2<.2014 3 2 3 30 46.034

    Еще одни даты на J.

    Abbath, 22 Апреля 2014

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

    +122

    1. 1
    }:;(1,5#3)<@}."_1'--T:: ',.~":,.10000+<.6!:0''

    Даты. Теперь на J.

    Abbath, 22 Апреля 2014

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

    +153

    1. 1
    print implode('-', array_reverse(explode('-', trim(substr($project->start_date, 0, count($project->start_date) - 9)))));

    Форматирует дату с Y-m-d в d-m-Y. Альтернатива для
    date_format(new DateTime($project->start_date), 'd-m-Y');

    djumpen, 22 Апреля 2014

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

    +72

    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
    if (match) {
    	formCell(sheet, rowPlus2, 0, 0, fulBorderCalignFont10, 1, false);
    	formCell(sheet, rowPlus2, 8, 8, fulBorderCalignFont10, 2, false);
    	formCell(sheet, rowPlus2, 14, 14, fulBorderCalignFont10, 3, false);
    	formCell(sheet, rowPlus2, 20, 20, fulBorderCalignFont10, 4, false);
    	formCell(sheet, rowPlus2, 26, 26, fulBorderCalignFont10, 5, false);
    	formCell(sheet, rowPlus2, 32, 32, fulBorderCalignFont10, 6, false);
    	formCell(sheet, rowPlus2, 42, 42, fulBorderCalignFont10, 7, false);
    	formCell(sheet, rowPlus2, 48, 48, fulBorderCalignFont10, 8, false);
    	formCell(sheet, rowPlus2, 54, 54, fulBorderCalignFont10, 9, false);
    	formCell(sheet, rowPlus2, 60, 60, fulBorderCalignFont10, 10, false);
    	formCell(sheet, rowPlus2, 66, 66, fulBorderCalignFont10, 11, false);
    	formCell(sheet, rowPlus2, 72, 72, fulBorderCalignFont10, 12, false);
    } else {
    	formCell(sheet, rowPlus2, 0, 0, fulBorderCalignFont10, 1, false);
    	formCell(sheet, rowPlus2, 8, 8, fulBorderCalignFont10, 2, false);
    	formCell(sheet, rowPlus2, 14, 14, fulBorderCalignFont10, 3, false);
    	formCell(sheet, rowPlus2, 20, 20, fulBorderCalignFont10, 4, false);
    	formCell(sheet, rowPlus2, 26, 26, fulBorderCalignFont10, 5, false);
    	formCell(sheet, rowPlus2, 32, 32, fulBorderCalignFont10, 6, false);
    	formCell(sheet, rowPlus2, 38, 38, fulBorderCalignFont10, 7, false);
    	formCell(sheet, rowPlus2, 42, 42, fulBorderCalignFont10, 8, false);
    	formCell(sheet, rowPlus2, 48, 48, fulBorderCalignFont10, 9, false);
    	formCell(sheet, rowPlus2, 54, 54, fulBorderCalignFont10, 10, false);
    	formCell(sheet, rowPlus2, 60, 60, fulBorderCalignFont10, 11, false);
    	formCell(sheet, rowPlus2, 66, 66, fulBorderCalignFont10, 12, false);
    	formCell(sheet, rowPlus2, 72, 72, fulBorderCalignFont10, 13, false);
    	formCell(sheet, rowPlus2, 78, 78, fulBorderCalignFont10, 14, false);
    }

    evg_ever, 17 Апреля 2014

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

    +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
    switch ($vs_TmpStr)
    {
    	case "230";
    		$vb_isCompl = true;
    		break;
    	case "11619";
    		$vb_isCalcul = true;
    		break;
    	case "11660";
    		$vb_isSevice = true;
    		break;
    	case "11668";
    		$vb_isCalcul = true;
    		break;
    	case "11670";
    		$vb_isCalcul = true;
    		break;
    	case "11669";
    		$vb_isCalcul = true;
    		break;
    	case "11678";
    		$vb_isSevice = true;
    		break;
    	case "11679";
    		$vb_isSevice = true;
    		break;
    	case "11681";
    		$vb_isSevice = true;
    		break;
    ...
    }

    125-ти строчный switch.

    any0ne2567, 17 Апреля 2014

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    if (ctype_space($text[$pos] && $pos < $len)) {
        while (ctype_space($text[$pos++]) && $pos < $len);
        $pos--;
    }

    Написал я когда-то такое и подумал: а какой смысл в $pos++ в последней итерации, если потом сразу $pos--?
    И тут до меня дошло, что
    while (ctype_space($text[$pos++]) && $pos < $len);
    это не то же самое, что
    while (ctype_space($text[$pos]) && $pos < $len) $pos++;
    ибо в первом случае $pos++ выполнится в последней итерации, даже если ctype_space возвратит false.
    И в итоге заоптимизировал до while (ctype_space($text[$pos]) && $pos < $len) $pos++; (уже без ифа и декремента).

    Мораль: нефиг выпендриваться (ставить инкременты и декременты в условия), если можно написать по-простому.

    arzeth, 14 Апреля 2014

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

    +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
    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
    var setIdToGridElements = function (gridId, gridConfig, idPrefix) {
    			var gridEl = Ext.get(gridId);
    			if (!gridEl) {
    				return;
    			}
    			var nodes = gridEl.dom.childNodes; // это массив всех элементов грида
    			var el;
    			for (var i = 0; i < nodes.length; i++) {
    				el = Ext.get(nodes[i].id);
    				if (el) {
    					var elements = el.dom.childNodes[i];
    					if (elements) {
    						var rowParameters = elements.children;				// это массив всех елементов строки
    						for (var j = 0; j < rowParameters.length; j++) {
    							var parameterEl = rowParameters[j].childNodes;
    							var newId = gridEl.id + '-' + gridConfig[0][j].key[1].name.bindTo + '-' + i;
    							parameterEl[1].className = "gridValue";
    							for (var k = 0; k < parameterEl.length; k++) {
    								parameterEl[k].id = newId + '-' + parameterEl[k].className;
    							}
    						}
    					}
    				}
    				// Выбираем все строки - элементы грида с ненулевым Id
    
    			}
    		};

    Авторские комментарии сохранены. Понимаю, что надо править и боюсь

    alex123098, 11 Апреля 2014

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

    +31

    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
    if(!$_SESSION["subscribe_user"]){
    
    		   $arr_subscribes = unserialize('a:94:{i:212;s:3:"212";i:228;s:3:"228";i:302;s:3:"302";i:304;s:3:"304";i:322;s:3:"322";i:354;s:3:"354";i:366;s:3:"366";i:382;s:3:"382";i:402;s:3:"402";i:406;s:3:"406";i:458;s:3:"458";i:484;s:3:"484";i:492;s:3:"492";i:548;s:3:"548";i:564;s:3:"564";i:572;s:3:"572";i:622;s:3:"622";i:646;s:3:"646";i:700;s:3:"700";i:706;s:3:"706";i:714;s:3:"714";i:716;s:3:"716";i:718;s:3:"718";i:730;s:3:"730";i:740;s:3:"740";i:746;s:3:"746";i:766;s:3:"766";i:770;s:3:"770";i:816;s:3:"816";i:826;s:3:"826";i:832;s:3:"832";i:834;s:3:"834";i:852;s:3:"852";i:884;s:3:"884";i:894;s:3:"894";i:914;s:3:"914";i:920;s:3:"920";i:982;s:3:"982";i:988;s:3:"988";i:1010;s:4:"1010";i:1194;s:4:"1194";i:1456;s:4:"1456";i:1528;s:4:"1528";i:1598;s:4:"1598";i:1644;s:4:"1644";i:1828;s:4:"1828";i:1938;s:4:"1938";i:1942;s:4:"1942";i:1990;s:4:"1990";i:2130;s:4:"2130";i:2154;s:4:"2154";i:2250;s:4:"2250";i:2272;s:4:"2272";i:2338;s:4:"2338";i:2714;s:4:"2714";i:2798;s:4:"2798";i:2892;s:4:"2892";i:3018;s:4:"3018";i:3178;s:4:"3178";i:3181;s:4:"3181";i:3182;s:4:"3182";i:43;s:2:"43";i:23;s:2:"23";i:25;s:2:"25";i:26;s:2:"26";i:27;s:2:"27";i:28;s:2:"28";i:2;s:1:"2";i:67;s:2:"67";i:74;s:2:"74";i:70;s:2:"70";i:72;s:2:"72";i:13;s:2:"13";i:14;s:2:"14";i:15;s:2:"15";i:16;s:2:"16";i:17;s:2:"17";i:18;s:2:"18";i:19;s:2:"19";i:20;s:2:"20";i:21;s:2:"21";i:22;s:2:"22";i:52;s:2:"52";i:66;s:2:"66";i:68;s:2:"68";i:36;s:2:"36";i:37;s:2:"37";i:38;s:2:"38";i:39;s:2:"39";i:40;s:2:"40";i:41;s:2:"41";i:42;s:2:"42";i:76;s:2:"76";i:78;s:2:"78";}');
    
    			$subscr=new subscribe_new();
    			$subscr->GetUserSubscr();
    
    			if(!count($subscr->user_subscribes)){
    				$subscr->user2subscr_table = 'utos';
    				$sql="select subscribe.* from subscribe LEFT JOIN enterprises ON enterprises.id=subscribe.enterprise where subscribe.visible='Y' AND (subscribe.enterprise = 0 OR enterprises.visible = 'Y') order by priority desc, week_day,id";
    				$res=@mysql_db_query($DB,$sql);
    				$all_subscribe=array();
    				while ($row=@mysql_fetch_assoc($res)):
    					$subscr->all_subscribes[$row["id"]]=$row;
    
    				endwhile;
    				
    				$q = $subscr->UpdateSubscr($arr_subscribes);
    				#print_r($arr_subscribes);
    				
    				#exit;
    			}
    
    	   }

    ну хрясь чтоле

    brainstorm, 07 Апреля 2014

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

    +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
    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
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    $manufacturer_id = JRequest::getInt('manufacturer_id');
                $label_id = JRequest::getInt('label_id');
                $vendor_id = JRequest::getInt('vendor_id');
               
                $view_name = "cart";
                $view_config = array("template_path"=>JPATH_COMPONENT."/templates/".$jshopConfig->template."/".$view_name);
                $view = $this->getView($view_name, getDocumentType(), '', $view_config);
                        if ($category->category_template=="") $category->category_template="default";
                $view->setLayout("category_".$category->category_template);        
         
                $jshopConfig->count_products_to_page = $category->products_page;
         
                $context = "jshoping.list.front.product";
                $contextfilter = "jshoping.list.front.product.cat.".$category_id;
                $orderby = $mainframe->getUserStateFromRequest( $context.'orderby', 'orderby', $jshopConfig->product_sorting_direction, 'int');
                $order = $mainframe->getUserStateFromRequest( $context.'order', 'order', $jshopConfig->product_sorting, 'int');
                $limit = $mainframe->getUserStateFromRequest( $context.'limit', 'limit', $category->products_page, 'int');
                if (!$limit) $limit = $category->products_page;
                $limitstart = JRequest::getInt('limitstart');
         
                $orderbyq = getQuerySortDirection($order, $orderby);
                $image_sort_dir = getImgSortDirection($order, $orderby);
                $field_order = $jshopConfig->sorting_products_field_select[$order];
                $filters = getBuildFilterListProduct($contextfilter, array("categorys"));
                $orderfield = $jshopConfig->category_sorting==1 ? "ordering" : "name";
                $sub_categories = $category->getChildCategories($orderfield, 'asc', $publish = 1);
                $dispatcher->trigger( 'onBeforeDisplayCategory', array(&$category, &$sub_categories) );
         
                if ($category->meta_title=="") $category->meta_title = $category->name;
                setMetaData($category->meta_title, $category->meta_keyword, $category->meta_description);
               
                $total = $category->getCountProducts($filters);
                $action = xhtmlUrl($_SERVER['REQUEST_URI']);
                       
                        $dispatcher->trigger('onBeforeFixLimitstartDisplayProductList', array(&$limitstart, &$total, 'category'));
                if ($limitstart>=$total) $limitstart = 0;
         
                $products = $category->getProducts($filters, $field_order, $orderbyq, $limitstart, $limit);
                        addLinkToProducts($products, $category_id);
         
                jimport('joomla.html.pagination');
                $pagination = new JPagination($total, $limitstart, $limit);
                $pagenav = $pagination->getPagesLinks();
               
                foreach($jshopConfig->sorting_products_name_select as $key=>$value){
                    $sorts[] = JHTML::_('select.option', $key, $value, 'sort_id', 'sort_value' );
                }
         
                insertValueInArray($category->products_page, $jshopConfig->count_product_select); //insert category count
                foreach ($jshopConfig->count_product_select as $key => $value){
                    $product_count[] = JHTML::_('select.option',$key, $value, 'count_id', 'count_value' );
                }
                $sorting_sel = JHTML::_('select.genericlist', $sorts, 'order', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"','sort_id', 'sort_value', $order );
                $product_count_sel = JHTML::_('select.genericlist', $product_count, 'limit', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"','count_id', 'count_value', $limit );
               
                $_review = JTable::getInstance('review', 'jshop');
                $allow_review = $_review->getAllowReview();
               
                if (!$category->category_ordertype) $category->category_ordertype = 1;
               
                $manufacuturers_sel = '';
                if ($jshopConfig->show_product_list_filters){
                    $filter_manufactures = $category->getManufacturers();
                    $first_manufacturer = array();
                    $first_manufacturer[] = JHTML::_('select.option', 0, _JSHOP_ALL, 'id', 'name');
                    if (isset($filters['manufacturers'][0])){
                        $active_manufacturer = $filters['manufacturers'][0];            
                    }else{
                        $active_manufacturer = 0;
                    }
                    $manufacuturers_sel = JHTML::_('select.genericlist', array_merge($first_manufacturer, $filter_manufactures), 'manufacturers[]', 'class = "inputbox" onchange = "submitListProductFilters()"','id', 'name', $active_manufacturer);
                }
                $display_list_products = (count($products)>0 || willBeUseFilter($filters));
         
                $dispatcher->trigger('onBeforeDisplayProductList', array(&$products));
                $view->assign('config', $jshopConfig);
                $view->assign('template_block_list_product', "cart/list_products.php");
                $view->assign('template_block_form_filter', "cart/form_filters.php");
                $view->assign('template_block_pagination', "cart/block_pagination.php");
                $view->assign('path_image_sorting_dir', $jshopConfig->live_path.'images/'.$image_sort_dir);
                $view->assign('filter_show_category', 0);
                $view->assign('display_pagination', $pagenav!="");
                $view->assign('rows', $products);
                $view->assign('count_product_to_row', $category->products_row);
                $view->assign('filters', $filters);
                $view->assign('display_list_products', $display_list_products);
                $view->assign('shippinginfo', SEFLink($jshopConfig->shippinginfourl,1));
                $view->display();

    Все это (пришлось еще отрезать строк 30) нужно таскать за собой для вывода списка товаров в нестандартном месте. При этом оно лежит в контроллере.
    Полный код: http://pastebin.com/jTj83ZpE
    (joomshopping)

    attn, 03 Апреля 2014

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

    −403

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    - (void)setButtonVisible:(bool)buttonVisible
    {
        if(isIpad)
        {
            id(*superSuperButtonVisible)(id, SEL, ...) = [[[self superclass] superclass] instanceMethodForSelector:@selector(setButtonVisible:)];
            superSuperButtonVisible(self, _cmd, buttonVisible);
        }
        else
        {
            [super setButtonVisible:buttonVisible];
        }
    }

    Угу, нет тут множественного наследования. Приходится наследоваться по очереди, а потом вызывать функции через одного.

    tirinox, 03 Апреля 2014

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