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

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    uses crt;
    var s:integer;
    begin
    readln(s);
    writeln(ord(s[0]));
    readln;
    end.

    dos, 20 Июня 2011

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

    +123

    1. 1
    this.Border1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(111)))), ((int)(((byte)(111)))), ((int)(((byte)(111)))));

    Встретилось такое внутри сгенеренной системой InitializeComponent()

    absolut, 17 Июня 2011

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

    +143

    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
    // find the start and end of the upload file.
    static FILE * _uploadGet(request *wp, unsigned int *startPos, unsigned *endPos) {
       
       FILE *fp=NULL;	
    	struct stat statbuf;	
    	unsigned char c, *buf; 
    	   
    	
    	if (wp->method == M_POST)
    	{
    	   fstat(wp->post_data_fd, &statbuf);
    		lseek(wp->post_data_fd, SEEK_SET, 0);
          
    		printf("file size=%d\n",statbuf.st_size);
    		fp=fopen(wp->post_file_name,"rb");
    		if(fp==NULL) goto error;
    	}
    	else goto error;
    
       
       //printf("_uploadGet\n");
       do
    	{
    		if(feof(fp))
    		{
    			printf("Cannot find start of file\n");
    			goto error;
    		}
    		c= fgetc(fp);
    		if (c!=0xd)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xa)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xd)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xa)
    			continue;
    		break;
    	}while(1);
    	(*startPos)=ftell(fp);
    
       if(fseek(fp,statbuf.st_size-0x200,SEEK_SET)<0) 
          goto error;
    	do
    	{
    		if(feof(fp))
    		{
    			printf("fmmgmt: Cannot find end of file\n");
    			goto error;
    		}
    		c= fgetc(fp);
    		if (c!=0xd)
    			continue;
    		c= fgetc(fp);
    		if (c!=0xa)
    			continue;
    		c= fgetc(fp);
    		if (c!='-')
    			continue;
    		c= fgetc(fp);
    		if (c!='-')
    			continue;
    		break;
    	}while(1);
    	(*endPos)=ftell(fp);
    
       return fp;
    error:
       return NULL;
    }

    Вот так вот китайцы парсят MIME при загрузке прошивки в роутер.

    SadKo, 12 Июня 2011

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

    +122

    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
    internal sealed class FontKeeper
    {
            private static readonly FontConverter s_converter = new FontConverter();
            private static readonly Regex s_font = new Regex(@"^(?<name>\w[\s\w]+);\s*(?<size>\d+)pt\s*(?:;(?<style>.*))?$", RegexOptions.IgnoreCase);
            private static readonly Regex s_style = new Regex(@"^\s*style\s*=\s*([\w\s,]+)$", RegexOptions.IgnoreCase);
            private const int defaultSize = 14;
    
            public FontKeeper(Font font) : this(s_converter.ConvertToString(font)) { }
    
            public FontKeeper(string fontString)
            {
                Match m = s_font.Match(fontString);
                if (!m.Success)
                    throw new ArgumentException("Неверный формат строки");
    
                Name = m.Groups["name"].Value.Trim();
                int sz;
                if (!int.TryParse(m.Groups["size"].Value, out sz))
                    sz = defaultSize;
                Size = sz;
    
                //Флаги стиля
                ParseStyle(m.Groups["style"].Value);
            }
    
            private void ParseStyle(string value)
            {
                Match m = s_style.Match(value);
                if (!m.Success) return;
    
                string[] styles = m.Groups[1].Value.Split(new[] { ',' });
                foreach (var style in styles)
                {
                    try
                    {
                        Style |= (FontStyle)Enum.Parse(typeof(FontStyle), style.Trim(), true);
                    }
                    catch { }
                }
            }
    
            public string Name { get; set; }
            public int Size { get; set; }
            public FontStyle Style { get; set; }
            public float FontFactor
            {
                get { return (float)Size / defaultSize; }
                set { Size = (int)(value * defaultSize); }
            }
    
            public Font CreateFont()
            {
                return new Font(Name, Size, Style);
            }
    }

    Небольшой класс для хранения и динамического изменения шрифтов

    lomomike, 10 Июня 2011

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

    +163

    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
    elseif (intval($countryID)>0 && intval($regionID)>0){
                    $SQL = "SELECT DISTINCT ".TABLE_PREFIX."hotels".LANG_PREFIX.".stars FROM  ".TABLE_PREFIX."hotels".LANG_PREFIX.", ".TABLE_PREFIX."regions".LANG_PREFIX."
                    WHERE   ".TABLE_PREFIX."regions".LANG_PREFIX.".id=".TABLE_PREFIX."hotels".LANG_PREFIX.".region_id
                    AND ".TABLE_PREFIX."regions".LANG_PREFIX.".id =".$regionID."";                               
                    $qRS = mysql_query ($SQL) or die ("<hr size=\"1\"><b>Не удалось выполнить: </b> \"" . $SQL . "\"<br>" . mysql_error());
                    if (mysql_num_rows($qRS)) {
                            while ($row = mysql_fetch_object($qRS)) {
                                    $stars[$row->stars]++;
                            }
                    }
                    krsort($stars);
                    foreach ($stars as $key=> $value) {
                            $ret .= get_hotels($key, 100, $regionID, $countryID);        
                    }

    Washington, 09 Июня 2011

    Комментарии (7)
  7. Python / Говнокод #6887

    −88

    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
    try:
            dday = time.strftime("%d", time.localtime(os.path.getmtime(path + d))).lstrip('0')
            dmonth = time.strftime("%m", time.localtime(os.path.getmtime(path + d))).lstrip('0')
            dhour = time.strftime("%H", time.localtime(os.path.getmtime(path + d))).lstrip('0')
            dmin = time.strftime("%M", time.localtime(os.path.getmtime(path + d))).lstrip('0')
            screenpath = os.listdir(spath)
            for screen in screenpath:
                sday = time.strftime("%d", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
                smonth = time.strftime("%m", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
                shour = time.strftime("%H", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
                smin = time.strftime("%M", time.localtime(os.path.getmtime(spath + screen))).lstrip('0')
                if dday == sday:
                    if dmonth == smonth:
                        if dhour == shour:
                            if dmin == smin:
                                scr = spath + screen
                                if scr:
                                    return str(scr)
                                else:
                                    return None
        except:
            return "None"

    Проверка даты создания двух файлов

    pztrn, 08 Июня 2011

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

    −318

    1. 1
    self._DEBUG=Debug.Debug(debug)

    В библиотеке xmpppy. Дебаг на дебаге.

    diok, 05 Июня 2011

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

    +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
    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
    // ...html-параша и верстка таблицей	
    <?php
    	
    	if (isset($charsetList)) {
    		echo "<tr>";
    		echo "<td class=\"inputfield\">";
    		echo __("Charset") . ":";
    		echo "</td>";
    		echo "<td>";
    		echo "<select id=\"DBCHARSET\">";
    		echo "<option></option>";
    		
    		$defaultCharSql = $conn->query("SHOW VARIABLES LIKE 'character_set_server'");
    		
    		if ($conn->isResultSet($defaultCharSql)) {
    			$defaultCharset = $conn->result($defaultCharSql, 0, "Value");
    		}
    		
    		foreach ($charsetList as $charset) {
    			echo "<option value=\"" . $charset . "\"";
    			
    			if (isset($defaultCharset) && $charset == $defaultCharset) {
    				echo ' selected="selected"';
    			}
    			
    			echo ">" . $charset . "</option>";
    		}
    		echo "</select>";
    		echo "</td>";
    		echo "</tr>";
    	}
    	
    	?>
    // ... html-параша

    Кусок кода системы управления MySQL. http://www.sqlbuddy.com/
    Посмотрел в код и потянуло блевать.

    Yurik, 03 Июня 2011

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

    +139

    1. 1
    2. 2
    3. 3
    img[width=120] {
    width: 120px;
    }

    Наткнулся в стилях dleшного шаблона....

    akim, 02 Июня 2011

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

    +147

    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
    make: предупреждение: Неправильный ход часов.  Сборка может быть неполной.
    mooncrafter@ubuntu:~/allthis/4_mesg$ make lol
    make: Внимание: Файл `Makefile' имеет будущее время 1,6e+03 s модификации
    gcc -c create_matrix/create_matrix.c
    gcc -c source/server.c source/lib/do.h source/lib/scmsg.h source/lib/msg.h
    gcc server.o -o server
    gcc -c source/client.c source/lib/do.h source/lib/scmsg.h source/lib/msg.h
    rm create_matrix.o server.o client.o source/lib/do.h.gch source/lib/scmsg.h.gch source/lib/msg.h.gch
    apt-get moo
             (__) 
             (oo) 
       /------\/ 
      / |    ||   
     *  /\---/\ 
        ~~   ~~   
    ...."Have you mooed today?"...
    sleep 1.5
    clear
    
    
    
    make: предупреждение: Неправильный ход часов.  Сборка может быть неполной.
    mooncrafter@ubuntu:~/allthis/4_mesg$ clear

    - называется перевёл чася на час наЗад!

    Mooncrafter, 23 Мая 2011

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