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

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

    −143.2

    1. 1
    2. 2
    3. 3
    4. 4
    # Это не баш, это cmd.exe, просто в ListBox'e нет интерпретатора Винды, что намекает как бы, но коль родственно немного
    # тем более покажемс Вам POSIX Винды
    
    SET a1 = [time /T] && SET b1 = [\time.%a1%.tmp] && whoami /all > %b1% && notepad %b1% && edit %b1%

    Это не баш, это cmd.exe, просто в ListBox'e нет интерпретатора Винды, что намекает как бы, но коль родственно немного, тем более покажемс Вам POSIX Винды.

    sergylens, 06 Апреля 2010

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

    +122.6

    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
    string[] mas_param = a.Split('_');
                this.s_sw_neraspred = mas_param[15];
                s_neraspred.Text = this.s_sw_neraspred;
                int i = a.IndexOf("_", 0, a.Length);
                sw_id = a.Substring(0, i);
                int j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                mf_id = a.Substring(j, i - j);
                //mf1=a.Substring(j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                ta_ed = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                this.s_op = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_rm = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_tm = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_sw = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                ta_sd = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                sw_sd = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                sw_ed = a.Substring(j, i - j);
                //mf_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                mf_topsw = a.Substring(j, i - j);
                //s_op_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_op_topsw = a.Substring(j, i - j);
                //s_rm_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_rm_topsw = a.Substring(j, i - j);
                //s_tm_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_tm_topsw = a.Substring(j, i - j);
                //s_sw_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_sw_topsw = a.Substring(j, i - j);            
            
    
                //ta
    
                ta_id = a.Split('_')[mas_param.Length-1];

    a - строка вида
    {0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_ {10}_{11}_{12}_{13}_{14}_{15}_{16}

    alex_donetsk, 01 Апреля 2010

    Комментарии (7)
  4. Си / Говнокод #2848

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    char str[STR_LEN + 1]; 
    
    strncpy(str, inpust_str, STR_LEN);
    xxx[STR_LEN] = '\0';
    
    str[ strlen(str) ] = ':';
    str[ strlen(str) + 1 ] = '1';
    str[ strlen(str) + 2 ] = '\0';

    Попытка добавить ":1" к строке.

    Первым же "str[ strlen(str) ] = ':';" гробим нулевой символ в конце строки. Дальнейшие вызовы "strlen" - просто фигня какая-то. Ну и портим память.

    benderlog, 23 Марта 2010

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

    +152.6

    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 str_replace ( search, replace, subject ) {	// Replace all occurrences of the search string with the replacement string
    	// 
    	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    	// +   improved by: Gabriel Paderni
    
    	if(!(replace instanceof Array)){
    		replace=new Array(replace);
    		if(search instanceof Array){//If search	is an array and replace	is a string, then this replacement string is used for every value of search
    			while(search.length>replace.length){
    				replace[replace.length]=replace[0];
    			}
    		}
    	}
    
    	if(!(search instanceof Array))search=new Array(search);
    	while(search.length>replace.length){//If replace	has fewer values than search , then an empty string is used for the rest of replacement values
    		replace[replace.length]='';
    	}
    
    	if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
    		for(k in subject){
    			subject[k]=str_replace(search,replace,subject[k]);
    		}
    		return subject;
    	}
    
    	for(var k=0; k<search.length; k++){
    		var i = subject.indexOf(search[k]);
    		while(i>-1){
    			subject = subject.replace(search[k], replace[k]);
    			i = subject.indexOf(search[k],i);
    		}
    	}
    
    	return subject;
    
    }

    function str_replace(search, replace, subject) { return subject.split(search).join(replace);}

    DrFreez, 22 Марта 2010

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php
        if (preg_match('/^mysql/', $string == 1)) {
            $dsn = $string;
        }
        ###
        ###
        ###
    ?>

    sultan, 17 Марта 2010

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

    +124.8

    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
    varnamebegin // начало имени новой переменной
    a // имя новой переменной
    varnameend // конец имени новой переменной
    varvaluebegin // начало значения новой переменной
    newarray // новый массив
    varvalueend // конец значения новой переменной
    varcallbegin // начало имени вызываемой переменной
    a // имя вызываемой переменной
    varcallend // конец имени вызываемой переменной
    push // добавить элементы в массив
    lcobjectsbegin // начало области добавляемых элементов
    bg // начало значения элемента массива
    codedn // code — символ, d — префикс для цифр, n — спец-символ для цифры "0"
    end // конец значения элемента массива
    bg // начало значения элемента массива
    codedo // code — символ, d — префикс для цифр, n — спец-символ для цифры "1"
    end // конец значения элемента массива
    lcobjectsend // конец области добавляемых элементов
    functioninit // аналог ()

    Создание массива с содержимым [0, 1] на одном из эзотерических ЯП. Фишка в том, что убраны все знаки препинания, цифры и т.д., оставлены лишь прописные латинские буквы.
    Интересно, как на таком ЯП будет выглядеть полностью валидная проверка E-Mail (наподобии этой — ex-parrot.com/pdw/Mail-RFC822-Address.html) ?

    eval, 17 Марта 2010

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

    +111.6

    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
    private ArrayList MNK(Matrix x, ArrayList y) {
    
                normalization(ref x);
    
                
    
                for (int i = 0; i < x.N; i++)
    
                    for (int j = 0; j < x.M; j++)
    
                        x.data[i, j] = Chebyshev.function(x.data[i,j],POWER_POLYNOM);
    
    
    
                Matrix yNew = Matrix.CreateMatrixFromArrayList(y);
    
                Matrix tranc = x.Tranc_Matrix(x);
    
                Matrix temp = x.Obernena_Matrix(x.Mul_Matrix(tranc, x));
    
                temp = x.Mul_Matrix(temp, tranc);
    
                temp = x.Mul_Matrix(temp, yNew);
    
                yNew = yNew.Mul_Matrix(x,temp);
    
    
    
                    return (returnValue(yNew, y));
    
            }
    
    
    //****************************************************
     #region
    
            private static ArrayList returnValue(Matrix yNew, ArrayList y)
    
            {
    
                ArrayList t = new ArrayList();
    
                Random r = new Random();
    
                double k = 2;
    
    
    
                for (int i = 0; i < y.Count; i++)
    
                {
    
                    if (y.GetHashCode() == y1.GetHashCode())
    
                        k = 1;
    
                    if (y.GetHashCode() == y2.GetHashCode())
    
                        k = 4000;
    
                    if (y.GetHashCode() == y3.GetHashCode())
    
                        k = 1000000;
    
    
    
                    t.Add((double)y[i] + ((double)(r.NextDouble() * k - k/2)));   
    
                }
    
                return t;           
    
            }
    
            #endregion

    вот как тру системные аналитики пишут свои прогнозы))))))))))

    white, 07 Марта 2010

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

    +157.4

    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
    while (count(array_diff(array_keys($rows), $roots)) > 0) 
    		{
    			 $theLeaves = $this->_getLeaves($rows);
    			 foreach ($theLeaves as $leafId) 
    			 {
    			 	if(isset($rows[$rows[$leafId]['parent_id']]['Menu']['data']) and 
                                               !is_array($rows[$rows[$leafId]['parent_id']]['Menu']['data']))
    			 		if(!is_array($rows[$rows[$leafId]['parent_id']]['Menu']['data']))
                                                   unset($rows[$rows[$leafId]['parent_id']]['Menu']['data']);
                                            
    				  if(isset($rows[$rows[$leafId]['parent_id']]['data']) and 
                                            !is_array($rows[$rows[$leafId]['parent_id']]['data']))
    			 	     if(!is_array($rows[$rows[$leafId]['parent_id']]['data']))
                                                unset($rows[$rows[$leafId]['parent_id']]['data']);
                                         
    				  $rows[$rows[$leafId]['parent_id']]['data'][] = $rows[$leafId];
    				  unset($rows[$leafId]);
    			 }
    		}

    пришел проектик на доработку. сижу, пытаюсь разобраться

    gesper, 04 Марта 2010

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

    +75.4

    1. 1
    2. 2
    3. 3
    4. 4
    if (!Float.valueOf("0.0").equals(price.getActualPrice()))
    {
    	return true;
    }

    Сравнение чисел (float) нездоровым способом.

    asolntsev, 04 Марта 2010

    Комментарии (7)
  11. JavaScript / Говнокод #2710

    +166.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function smla(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':)';}
    function smls(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='>( ';}
    function smld(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':D';}
    function smlf(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='B)';}
    function smlg(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='%)';}
    function smlh(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':(';}
    function smlj(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':o';}
    function smlw(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='^_^';}
    function smlk(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+='<_<';}
    function smll(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=';)';}
    function smlq(){parent.window.document.getElementById('soob').focus();parent.window.document.getElementById('soob').value+=':p';}

    Ещё один китаец. Вставляет смайлы в текстовое поле вот таким вот кодом. Источник — http://mirtorrent.ru/css/pppm.js

    Infamous, 03 Марта 2010

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