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

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

    +82

    1. 1
    getField().setText(objToString(stringToObj(getField().getText())));

    Moloth, 06 Мая 2013

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

    +170

    1. 1
    if (window.IsLocking !== [].xxx)

    Проверка на undefined

    Zergatul, 22 Апреля 2013

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

    +142

    1. 1
    var_dump( ((int) 0 == (string) "test") ); // TRUE

    Бляааа...

    deep, 20 Апреля 2013

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

    +132

    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
    <div class="breadcrumbs">
      <ul>
        <li>
          @if (curMenu != null)
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            if (depth == 1)
            {
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 2)
            {
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a> <span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 3)
            {
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 4)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 5)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 6)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 7)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }
            else if (depth == 8)
            {
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Menu2.Url">@(curMenu.Menu2.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <a href="/@curMenu.Menu2.Url">@(curMenu.Menu2.Title)</a><span class="breadcrumbs__dash"> / </span>
              <span>@(curMenu.Title)</span>
            }                                  
          }
          else if (ViewBag.Title != null && url!="/")
          {
            <a href="@Url.Action("index", "main")">Главная</a><span class="breadcrumbs__dash"> / </span>
            <span>@ViewBag.Title</span>
          }
        </li>
      </ul>
    </div>

    Хлебные крошки в каталоге "неограниченной" вложенности.

    validol, 19 Апреля 2013

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

    +159

    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
    if(@$_POST['submit']) {
            
    	$title = "title";
    	$string = "";
    	$equal = "=";
    	$amper = "&";
            $to = '[email protected]';
            $from='[email protected]';
    
    	foreach($_POST as $key => $value) {
    		foreach($value as $v) {
    			$string=$string.$key.$equal.$v.$amper;
    		}
    	}
    
            mail($to, $title, $string, 'From:'.$from);
    }

    clauclauclau, 04 Апреля 2013

    Комментарии (6)
  7. Куча / Говнокод #12831

    −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
    <tr style = 'height:20px;'>
    	<td class =len_ss >
    		<text>имя категории</text>
    	</td>
    	<td>
    		<text>тип категории</text>
    	</td>
    	<td>
    		<text>алиас категории</text>
    	</td>
    	<td>
    		<text>hidden категории</text>
    	</td>
    </tr>

    Попросил новичка сделать шапку для таблицы...

    Snickers, 30 Марта 2013

    Комментарии (6)
  8. Objective C / Говнокод #12823

    −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
    - (CGPoint)itemTopLeftPoint
    {
        CGRect bounds = CGRectMake(0,0, 100, 100);// [[UIScreen mainScreen] bounds];
        CGFloat width = bounds.size.width;
        
        if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {
            width = bounds.size.height;
        }
        
        CGFloat x = 0, y = 0;
        
        x = (width - (self.numberOfItemsPerRow * AGIPC_ITEM_SIZE.width)) / (self.numberOfItemsPerRow + 1);
        y = x;
        return CGPointMake(x, y);
    }

    Приспичило мне тут показать кастомный контроллер в модальном окне. А он вместо контента показывает чушь, расчитанную под другую ширину.
    Обнаружено в ходе раскопок.

    krypt, 29 Марта 2013

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

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static Dictionary<object, object> _cache = new Dictionary<object, object>();
    .........
    if( _cache.ContainsKey( key ) )
    {
      lock( syncRoot )
      {
        _cache[key] = value;
        return;
      }
    }
    _cache.Add( key, value );

    Бараньи мозги.

    grobotron, 25 Марта 2013

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    if (Database::getDbType() == 'pgsql')
          $stmt = Database::getInstance()->dbh->prepare("SELECT COUNT(*) AS count FROM torrent WHERE tracker = :tracker AND torrent_id = :id");
    else
          $stmt = Database::getInstance()->dbh->prepare("SELECT COUNT(*) AS `count` FROM `torrent` WHERE `tracker` = :tracker AND `torrent_id` = :id");

    https://github.com/ElizarovEugene/TorrentMonitor/blob/master/class/Database.class.php#L625 УПРЛС

    DrFreez, 24 Марта 2013

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

    +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
    function _subqery_helper ($uri){
    static $i;
    		$i++;
    
    		if ((is_array($uri)) && (!empty($uri))) {
    			$keyword = array_pop($uri); //извлекаем последний элемент
    			
    			if ($i==1) 
    			{
    				$subqery = 'AND item.keyword= '.$this->db->escape($keyword).' '.(count($uri)? 'AND parent IN 
    				('.$this->_subqery_helper($uri).')' : '');
    			}
    			
    			elseif ($i > 1) 
    			{
    				$subqery = 'SELECT id FROM '.$this->db->dbprefix($this->table).' WHERE keyword = '.$this->db->escape($keyword).' AND parent '.(count($uri)? 'IN 
    				('.$this->_subqery_helper($uri).')' : ' = 0');
    			}
    		}
    		return $subqery;
    }

    массив $url очень простой:
    1=>"str1",2=>"str2",3=>"str3"

    это непонятная итерационная функция, которая вообще непонятно зачем такая сложная....

    xoptov, 15 Марта 2013

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