1. C# / Говнокод #11636

    +140

    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
    // http://stackoverflow.com/questions/12033790/locknew-object-cargo-cult-or-some-crazy-language-special-case
    private void foo()
    {
        if (InvokeRequired)
        {
            lock (new object())
            {
                if (m_bar!= null)
                    Invoke(new fooDelegate(foo), new object[] { });
            }
        }
        else
        {
            if(OnBazChanged != null)
                OnBazChanged();
        }
    }

    По одной из версий, этот бессмысленный lock - это "оптимизация", раньше было поле private readonly object lockObj = new object();
    P.S. Поставьте таки autocomplete="off" в поле ввода капчи <input class="captcha" id="formElm_captcha" name="captcha" type="text" value=""> - задолбала она старые капчи предлагать.

    victor-homyakov, 23 Августа 2012

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

    +67

    1. 1
    $msg = (($this->data[0] == '1' || $this->auth->demo == 1) ? "orderCheck" : "orderInsert")." ".(($this->data[4] == '1') ? "1" : "0")."*|*".$a[$ww][$objs[0][0]][0]['o']."%|%".$a[$ww][$objs[0][0]][0]['h']."%|%%|%".$a[$ww][$objs[0][0]][0]['e']."%|%".$this->data[9].$hord."*|*".$this->regiond['phone_code'].(($this->auth->demo==1) ? $this->regiond['demo_phone'] : $this->auth->phone)."*|*".$nord."*|*".$this->data[7]."*|*".$this->regiond['phone_code'].(($this->auth->demo==1) ? $this->regiond['demo_phone'] : $this->data[6])."*|*".$this->data[5]/*(($this->data[5] == '2' && $this->regiond['lux'] == '1') ? "deluxe" : "")*/."*|*".$this->java."*|*".$this->data[13];

    Картина Репина. PHP притворяется регэкспом.

    blessed, 23 Августа 2012

    Комментарии (0)
  3. Objective C / Говнокод #11634

    −99

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // WTF is 8.5? Oo I will never, ever hardcode some random values.
    	linkStatusImage.frame = CGRectMake (5, height / 2 - 8.5, 17, 17);
    	descriptionLabel.frame = CGRectMake (27, 5, width - 32 - rightMargin, 20);
    	authorLabel.frame = CGRectMake (27, 30, width - 32 - rightMargin, 20);
    	addressLabel.frame = CGRectMake (27, 55, width - 32 - rightMargin, height - 60);
    	separatorImage.frame = CGRectMake (0, height - 2, separatorImage.image.size.width, 2);
    	favButton.frame = CGRectMake (width - 22, height / 2 - 8.5, 17, 16);

    byss, 23 Августа 2012

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

    +115

    1. 1
    2. 2
    3. 3
    4. 4
    -- Настало время запостить самое главное гавно Хаскеля:
    -- http://www.johndcook.com/blog/2010/05/18/pure-functions-have-side-effects/
    -- У чистых функций всегда есть side-effects, которые выражаются в пожирании памяти и CPU. 
    -- Очевидно конечно, но почему об этом не орут на первой странице каждой книги по функциональному программированию?

    Я проверил, код компилируется:
    http://ideone.com/sozuV

    HaskellGovno, 23 Августа 2012

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

    +48

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    //Функция проверки закачиваемого файла
    function fileNameCheck($file) {
    	if(preg_match("/[^a-z\d\-\._]/i", $file)) {
    		return true;
    	}
    	return false;
    }

    Приятно удивляет соответствие названия функции с её возвращаемым значением.

    Edward, 22 Августа 2012

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

    +53

    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
    class MYSQL_ACTIONS
    {      
    		public $arguments = array();
    		public $values;
    		public $rows;
    		public $check = true;
    		public $list_array = array();
    		function __construct ()
    		{
    			$this->arguments = func_get_args();
    			$z = '';
    			foreach ($this->arguments as $value)
    			{
    				$y ="$value,";
    				$z .= $y;
    			}
    			$this->rows = substr("$z",0,-1);
    		}
    		function check_isset()
    		{
    			$argument = func_get_args();
    			for ($i = 0; $i < count($argument); $i++)
    			{
    				foreach ($argument as $value)
    				{      
    					${$value} = $this->list_array[$i++];
    				}
    			 
    			}
    		 
    			for($i = 0; $i < count($argument); $i++)
    			{
    				$x = ${$argument[$i]};
    				if (empty($x))
    				{
    					$this->check = false;
    					break;
    				}
    			}
    		}
    		function mysql_action($table)
    		{
    			$processing = new GET_(processing);
    			$date = date("Y-m-d H:i:s");
    		 
    			for ($i = 0; $i < count($this->arguments); $i++)
    			{
    				foreach ($this->arguments as $value)
    				{      
    					${$value} = $this->list_array[$i++];
    				}
    						 
    			}
    		 
    			$x ='';
    			foreach ($this->arguments as $value)
    			{
    				$y =" '${$value}',";
    				$x .= $y;
    			}
    			$this->values = substr("$x",0,-1);
    		 
    			if ($processing->variable == "add")
    			{              
    				if ($this->check == true)
    				{
    					$result = mysql_query("INSERT INTO {$table} ({$this->rows}) VALUES ({$this->values})");
    					if ($result == true)
    					{
    						echo "";
    					}
    					else
    					{
    						echo "";
    					}
    				}
    				else
    				{
    					echo "";
    				}
    			}
    		}
    }

    Очередное говно с просторов интернета

    BioMan, 22 Августа 2012

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

    +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
    delegate β ƒ<α, β>(α x);
    delegate α γ<α>(γ<α> f);
     
    static ƒ<α, β> Y<α, β>(ƒ<ƒ<α, β>, ƒ<α, β>> f) {
      return new γ<ƒ<α, β>>(h => F => f(h(h))(F))(h => F => f(h(h))(F));
    }
    
    static ƒ<int, int> Fact(ƒ<int, int> fact) {
      return n => (n == 0) ? 1 : n * fact(n - 1);
    }
    ...
    var fact = Y<int, int>(Fact);
    Console.WriteLine("fact(6) = {0}", fact(6));

    HaskellGovno, 22 Августа 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <select>
    	<option class="a2" value="0" selected="selected">любой возраст</option>
    	<option class="a2" value="1">0 мес - 6 мес</option>
    	<option class="a2" value="2">0 мес - 12 мес</option>
    </select>

    selected="selected" для элемента, выбираемого по дефолту - зачем?
    ps. Код - кусок статичного html.

    domaster, 22 Августа 2012

    Комментарии (10)
  9. Pascal / Говнокод #11628

    +106

    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
    function ReplaceUrl(txt: WideString): WideString;
    var
      i, j: integer;
      tmp, Url: WideString;
    begin
      Result := '';
      I := 1;
      while I <= Length(txt) do
      begin
        tmp := '';
        if WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6], 'http://') or
           WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6], 'ed2k://') or
           WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5],          'ftp://') or
           WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3],                            'www.') or
           WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6]+txt[i+7], 'https://') then
        begin
          Url := '';
          for j := I to Length(txt) do
          begin
            if (txt[j] <> ' ') and (ord(txt[j]) < 255) then
              Url := Url + txt[J]
            else
              Break;
          end;
     
          Result := Result + Format(C_HTML_URL, [Url, Url]);
     
          I := J;
        end else
        begin
          Result := Result + txt[I];
     
          Inc(I);
        end;
      end;
     
    end;

    http://www.bvbcode.com/code/vhk2e8rb-1638045

    63F45EF45RB65R6VR, 21 Августа 2012

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

    +56

    1. 1
    2. 2
    3. 3
    4. 4
    $data = $this->db->qp($q=(($type == 1 && $this->auth->demo == 0) ? '(SELECT Favorite_Name as s, CONCAT(oname,\'|\',House,\'|\',Enter) as s2, Id as id, \'1\' as t, null as m, IF(LEFT(LOWER(TRIM(Favorite_Name)), '.$c.')=\''.$sword.'\', 0, IF(LEFT(LOWER(TRIM(oname)), '.$c.')=\''.$sword.'\', 1, 2)) as od, \'1\' as t2 FROM :Cabinet_Favorite_Objects: WHERE Client_Phone=\'7'.$this->auth->phone.'\' && (lower(Favorite_Name) LIKE \'%'.$sword.'%\' || lower(oname) LIKE \'%'.$sword.'%\') ORDER BY od ASC, Favorite_Name'.$lim.')
    		UNION ALL
    		(SELECT addr as s, \'1\' as s2, id as id, \'2\' as t, null as m, IF(LEFT(LOWER(TRIM(addr)), '.$c.')=\''.$sword.'\', 0, 1) as od, \'2\' as t2 FROM :cabinet_history_objects: WHERE cid=\''.$this->auth->adata['IDClient'].'\' && lower(addr) LIKE \'%'.$sword.'%\' ORDER BY od ASC, num, addr DESC'.$lim.')
    		' : '').(($type == 1 && $this->auth->demo == 0 && $c > 0) ? ' UNION ALL ' : '').(($c > 0) ? '(SELECT objectName as s, objectMetaType as s2, objectID as id, \'3\' as t, objectAddress as m, IF(LEFT(LOWER(TRIM(SearchField)), '.$c.')=\''.$sword.'\', 0, 1) as od, IF(objectMetaType=\'0\', 3, IF(objectMetaType=\'100\', 4, 5)) as t2 FROM :Cabinet_Objects: WHERE lower(SearchField) LIKE \'%'.$sword.'%\' ORDER BY od ASC, objectMetaType ASC, s ASC'.$lim.')' : ''), '', 'select');

    Получение списка доступных адресов для заказа такси.

    blessed, 21 Августа 2012

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