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

    +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
    private String GetCardType(String creditCardType)
            {
                switch (creditCardType)
                {
                    case "A":
                        return "A";
                    case "Z":
                        return "D";
                    case "M":
                        return "M";
                    case "V":
                        return "V";
                }
    
                return "0";
            }

    startrack, 10 Июня 2013

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

    +157

    1. 1
    2. 2
    3. 3
    function firm_out_current_rayon($frwb = 0)
    {
    	global $_conf;

    Current rayon

    TBoolean, 10 Июня 2013

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

    +134

    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
    class Slovo
        {
            public string Word;
            public int Count;
            public Slovo(string slovo, int kolichestvo)
            {
                Word = slovo;
                Count = kolichestvo;
            }
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                string s = "Один два четыре восемь число один и два дают вместе восемь а один умножить на один будет один";
                List<string> word = new List<string>();
                List<int> count = new List<int>();
                string[] word_collection = s.ToLower().Split(' ');
                foreach (string str in word_collection) if (!word.Contains(str))
                    {
                        word.Add(str);
                        count.Add(1);
                    }
                    else count[word.IndexOf(str)]++;
                List<Slovo> spisok = new List<Slovo>();
                for (int i = 0; i < word.Count; i++) spisok.Add(new Slovo(word[i], count[i]));
                spisok.Sort((a, b) => b.Count - a.Count);
                foreach (Slovo slovo in spisok) Console.WriteLine(slovo.Word.PadRight(12) + slovo.Count.ToString());
                Console.ReadKey();
            }
        }

    Найти в строке самые частоповторяющиеся слова

    sbs, 10 Июня 2013

    Комментарии (33)
  4. C# / Говнокод #13135

    +124

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private void HideActiveButtons()
    {
        try
        {
    
        }
        catch (Exception)
        {
            throw;
        }
    }

    Откопано в форме Windows Forms в страшном legacy-коде.

    someone, 09 Июня 2013

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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function mpeval($file_name, $arg = array(), $vr = 1){
    	global $conf;
    	foreach(explode(':', $conf['fs']['path'], 2) as $k=>$v)
    		if (file_exists($file = "$v/$file_name")) break;
    	if (!file_exists($file = "$v/$file_name")) return "<div style=\"margin-top:100px; text-align:center;\"><span style=color:red;>Ошибка доступа к файлу</span> $v/$file_name</div>";
    
    	ob_start();
    	eval('?>'. strtr(file_get_contents($file), array('<? die;'=>'<?', '<?php die;'=>'<?php')));
    	$content = ob_get_contents();
    	ob_end_clean();
    	return $content;
    }

    eval`им вовсю

    nkarakin, 09 Июня 2013

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

    +168

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <script type="text/javascript">
     <!--
     var h=(new Date()).getHours();
     if (h > 23 || h < 7) document.write("Доброй ночи!");
     if (h > 6 && h < 12) document.write("Доброе утро!");
     if (h > 11 && h < 19) document.write("Добрый день!");
     if (h > 18 && h < 24) document. write("Добрый вечер!");
     if (h > 25 && h < 1000) document. write("Доброго апокалипсиса!");
     -->
     </script>

    Найдено на одном из клиентских сайтов:

    lionovsky, 09 Июня 2013

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    foreach(mpql(mpqw("SHOW TABLES WHERE Tables_in_{$conf['db']['name']} LIKE \"{$conf['db']['prefix']}{$arg['modpath']}\_%\"")) as $k=>$v){
    	$t = implode("_", array_slice(explode("_", $v["Tables_in_{$conf['db']['name']}"]), 2));
    	if(!array_key_exists($t, (array)$tpl)){
    		$tpl[ $t ] = mpqn(mpqw("SELECT * FROM {$conf['db']['prefix']}{$arg['modpath']}_{$t}"));
    	}
    }// mpre($tpl);

    Тотальный и беспросветный пиздец.

    nkarakin, 09 Июня 2013

    Комментарии (50)
  8. C++ / Говнокод #13131

    +14

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    template<typename U>
    shared_ptr(const shared_ptr<U> & ptr) throw()
    	: m_value(0)
    	, m_ref_count(0)
    {
    	m_value = static_cast<T *>(ptr.get());
    	if(m_value)
    	{
    		m_ref_count = reinterpret_cast<const shared_ptr &>(ptr).m_ref_count;
    		++*m_ref_count;
    	}
    }

    Выражаясь метафорично, я работаю на велосипедном заводе.

    Xom94ok, 09 Июня 2013

    Комментарии (25)
  9. SQL / Говнокод #13130

    −160

    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
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    select model,
    case when c1>='0' and c1<='9' then cast(c1 as integer) else 0 end +
    case when c2>='0' and c2<='9' then cast(c2 as integer) else 0 end +
    case when c3>='0' and c3<='9' then cast(c3 as integer) else 0 end +
    case when c4>='0' and c4<='9' then cast(c4 as integer) else 0 end +
    case when c5>='0' and c5<='9' then cast(c5 as integer) else 0 end +
    case when c6>='0' and c6<='9' then cast(c6 as integer) else 0 end +
    case when c7>='0' and c7<='9' then cast(c7 as integer) else 0 end +
    case when c8>='0' and c8<='9' then cast(c8 as integer) else 0 end +
    case when c9>='0' and c9<='9' then cast(c9 as integer) else 0 end +
    case when c10>='0' and c10<='9' then cast(c10 as integer) else 0 end +
    case when c11>='0' and c11<='9' then cast(c11 as integer) else 0 end +
    case when c12>='0' and c12<='9' then cast(c12 as integer) else 0 end +
    case when c13>='0' and c13<='9' then cast(c13 as integer) else 0 end +
    case when c14>='0' and c14<='9' then cast(c14 as integer) else 0 end +
    case when c15>='0' and c15<='9' then cast(c15 as integer) else 0 end +
    case when c16>='0' and c16<='9' then cast(c16 as integer) else 0 end +
    case when c17>='0' and c17<='9' then cast(c17 as integer) else 0 end +
    case when c18>='0' and c18<='9' then cast(c18 as integer) else 0 end +
    case when c19>='0' and c19<='9' then cast(c19 as integer) else 0 end +
    case when c20>='0' and c20<='9' then cast(c20 as integer) else 0 end +
    case when c21>='0' and c21<='9' then cast(c21 as integer) else 0 end +
    case when c22>='0' and c22<='9' then cast(c22 as integer) else 0 end +
    case when c23>='0' and c23<='9' then cast(c23 as integer) else 0 end +
    case when c24>='0' and c24<='9' then cast(c24 as integer) else 0 end +
    case when c25>='0' and c25<='9' then cast(c25 as integer) else 0 end +
    case when c26>='0' and c26<='9' then cast(c26 as integer) else 0 end +
    case when c27>='0' and c27<='9' then cast(c27 as integer) else 0 end +
    case when c28>='0' and c28<='9' then cast(c28 as integer) else 0 end +
    case when c29>='0' and c29<='9' then cast(c29 as integer) else 0 end +
    case when c30>='0' and c30<='9' then cast(c30 as integer) else 0 end +
    case when c21>='0' and c31<='9' then cast(c31 as integer) else 0 end +
    case when c22>='0' and c32<='9' then cast(c32 as integer) else 0 end +
    case when c23>='0' and c33<='9' then cast(c33 as integer) else 0 end +
    case when c34>='0' and c34<='9' then cast(c34 as integer) else 0 end +
    case when c35>='0' and c35<='9' then cast(c35 as integer) else 0 end +
    case when c36>='0' and c36<='9' then cast(c36 as integer) else 0 end +
    case when c37>='0' and c37<='9' then cast(c37 as integer) else 0 end +
    case when c38>='0' and c38<='9' then cast(c38 as integer) else 0 end +
    case when c39>='0' and c39<='9' then cast(c39 as integer) else 0 end +
    case when c40>='0' and c40<='9' then cast(c40 as integer) else 0 end +
    case when c41>='0' and c41<='9' then cast(c41 as integer) else 0 end +
    case when c42>='0' and c42<='9' then cast(c42 as integer) else 0 end +
    case when c43>='0' and c43<='9' then cast(c43 as integer) else 0 end +
    case when c44>='0' and c44<='9' then cast(c44 as integer) else 0 end +
    case when c45>='0' and c45<='9' then cast(c45 as integer) else 0 end +
    case when c46>='0' and c46<='9' then cast(c46 as integer) else 0 end +
    case when c47>='0' and c47<='9' then cast(c47 as integer) else 0 end +
    case when c48>='0' and c48<='9' then cast(c48 as integer) else 0 end +
    case when c49>='0' and c49<='9' then cast(c49 as integer) else 0 end +
    case when c50>='0' and c50<='9' then cast(c50 as integer) else 0 end from(
    select model,
    coalesce(substring(m,1,1),'0') as c1,
    coalesce(substring(m,2,1),'0') as c2,
    coalesce(substring(m,3,1),'0') as c3,
    coalesce(substring(m,4,1),'0') as c4,
    coalesce(substring(m,5,1),'0') as c5,
    coalesce(substring(m,6,1),'0') as c6,
    coalesce(substring(m,7,1),'0') as c7,
    coalesce(substring(m,8,1),'0') as c8,
    coalesce(substring(m,9,1),'0') as c9,
    coalesce(substring(m,10,1),'0') as c10,
    coalesce(substring(m,11,1),'0') as c11,
    coalesce(substring(m,12,1),'0') as c12,
    coalesce(substring(m,13,1),'0') as c13,
    coalesce(substring(m,14,1),'0') as c14,
    coalesce(substring(m,15,1),'0') as c15,
    coalesce(substring(m,16,1),'0') as c16,
    coalesce(substring(m,17,1),'0') as c17,
    coalesce(substring(m,18,1),'0') as c18,
    coalesce(substring(m,19,1),'0') as c19,
    coalesce(substring(m,20,1),'0') as c20,
    coalesce(substring(m,21,1),'0') as c21,
    coalesce(substring(m,22,1),'0') as c22,
    coalesce(substring(m,23,1),'0') as c23,
    coalesce(substring(m,24,1),'0') as c24,
    coalesce(substring(m,25,1),'0') as c25,
    coalesce(substring(m,26,1),'0') as c26,
    coalesce(substring(m,27,1),'0') as c27,
    coalesce(substring(m,28,1),'0') as c28,
    coalesce(substring(m,29,1),'0') as c29,
    coalesce(substring(m,30,1),'0') as c30,
    coalesce(substring(m,31,1),'0') as c31,
    coalesce(substring(m,32,1),'0') as c32,
    coalesce(substring(m,33,1),'0') as c33,
    coalesce(substring(m,34,1),'0') as c34,
    coalesce(substring(m,35,1),'0') as c35,
    coalesce(substring(m,36,1),'0') as c36,
    coalesce(substring(m,37,1),'0') as c37,
    coalesce(substring(m,38,1),'0') as c38,
    coalesce(substring(m,39,1),'0') as c39,
    coalesce(substring(m,40,1),'0') as c40,
    coalesce(substring(m,41,1),'0') as c41,
    coalesce(substring(m,42,1),'0') as c42,
    coalesce(substring(m,43,1),'0') as c43,
    coalesce(substring(m,44,1),'0') as c44,
    coalesce(substring(m,45,1),'0') as c45,
    coalesce(substring(m,46,1),'0') as c46,
    coalesce(substring(m,47,1),'0') as c47,

    Один из вариантов решения задачи с форума сайта sql-ex (может стебный):
    Посчитать сумму цифр в номере каждой модели из таблицы Product
    Вывод: номер модели, сумма цифр

    Полный код все равно не помещается, значит его нельзя выдать за свой.

    crastinus, 08 Июня 2013

    Комментарии (17)
  10. ActionScript / Говнокод #13129

    −170

    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
    public function set flip(value:Boolean):void {
        if (this.object.flip != value) {
            this.object.flip = value;
            this.clearCells();
            var cell:Cell = this.cell;
        }
    }
    
    public function get cell():Cell {
        if (!this._cell) {
            createCell();
        }
        return this._cell;
    }

    Ненавижу подергивание.

    kyzi007, 07 Июня 2013

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