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

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

    +102

    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 static string GetRootedCurrentConfigurationFile(string configurationFile)
    {
    if (string.IsNullOrEmpty(configurationFile))
    {
    throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFile");
    }
    if (!File.Exists(configurationFile))
    {
    throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionConfigurationLoadFileNotFound, new object[] { configurationFile }));
    }
    if (!Path.IsPathRooted(configurationFile))
    {
    return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configurationFile);
    }
    return configurationFile;
    }

    Собснно Говнокод by Microsoft (Ent Lib 5.0.414.0)

    TrueLauncher, 30 Июля 2010

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

    +163

    1. 1
    if(in_array($rating,array_keys($ratings))) ...

    ужос средь бела дня)

    xakki, 29 Июля 2010

    Комментарии (12)
  4. bash / Говнокод #3800

    −126

    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
    start() {
      echo "starting Adaptec Storage Manager agent ..."
      kill `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sleep 2
      kill -9 `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sh /usr/StorMan/StorAgnt.sh >/dev/null 2>&1 &
      sleep 1
      echo
    }
    
                                                                    
    stop() {
      echo "stopping Adaptec Storage Manager agent ..."
      kill `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sleep 2
      kill -9 `ps axwww | grep java | grep StorMan | grep ManagementAgent | cut -b 1-6` 1>/dev/null 2>&1
      sleep 1
      echo
    }

    Кусок скрипта для RAID от фирмы Adaptec. Боюсь смотреть, что они там в java накодили.

    icCE, 28 Июля 2010

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

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    BYTE p1,p2,p3,p4;
    CString p;
    ipa.GetAddress(p1,p2,p3,p4);
    p.Format("%d.", p1);
    s = p;
    p.Format("%d.", p2);
    s += p;
    p.Format("%d.", p3);
    s += p;
    p.Format("%d", p4);
    s += p;
    AfxMessageBox(s);

    книга "Microsoft Visual Studio и MFC", автор Т. Сидорина
    ранее были объявлены
    CIPAddressCtrl ipa;
    CString s;

    s.Format ("%d.%d.%d.%d", p1, p2, p3, p4); //мы не исчем лёгких путей

    daemon_master, 23 Июля 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    void get_tomorrow_date( struct timeval *date ) 
    { 
    sleep( 86400 ); // 60 * 60 * 24 
    gettimeofday( date, 0 ); 
    }

    Программистский шедевр на индусском форуме на тему «как узнать завтрашнюю дату» остался непревзойденным.

    REDNES, 22 Июля 2010

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

    +172

    1. 1
    function getCodeByCode(code)

    хорошее название функции

    mozg_raka, 20 Июля 2010

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

    +141

    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
    int AnalizingHeaderLine(char* HeadLine)
    {
    	if(HeadLine==NULL) return -1;
    	if(strlen(HeadLine)==0) return 0;
    
    	if(!strncmp(HeadLine,"HTTP/",5))
    		ProcessStatusHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "date:",5))
    		ProcessDateHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "server:",7))
    		ProcessServerHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "last-modified:",14))
    		ProcessLastModHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "content-type:",13))
    		ProcessContTypeHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "content-length:",15))
    		ProcessContLenHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "pragma:",7))
    		ProcessPragmaHL(HeadLine);
    	else if(!strncmp(strlwr(HeadLine), "Connection",10))
    		ProcessConnectHL(HeadLine);
    	else printf("Unknown header line: %s\n", HeadLine);
    	return strlen(HeadLine);
    }
    
    int ProcessStatusHL(char* HeadLine)
    {
    	short MinVer, MajVer;
    	char ResultStr[32];
    	char Num;
    	short Code;
    	Num = sscanf(HeadLine, "HTTP/%d.%d %d %s", &MinVer, &MajVer, &Code, ResultStr);
    	if(Num!=3 && Num!=4) 
    	{	printf("Error status string\n");
    		return -1;
    	}
    	return Code;
    }
    
    int ProcessDateHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessServerHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessLastModHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessContTypeHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessContLenHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessPragmaHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }
    
    int ProcessConnectHL(char* HeadLine)
    {
    	printf("%s\n",HeadLine);
    	return 0;
    }

    CGI. Обработка HTTP-заголовков. Rev. 1.0

    absolut, 20 Июля 2010

    Комментарии (12)
  9. JavaScript / Говнокод #3724

    +152

    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
    Map = function() {
        this._entries = new Array();
    }
    
    Map.prototype.containsKey = function(key) {
        return this.getEntry(key)!=null;
    }
    
    Map.prototype.get = function(key) {
        var entry = this.getEntry(key);
        return entry!=null ? entry.value : null;
    }
    
    Map.prototype.put = function(key, value) {
        var entry = this.getEntry(key);
        if (entry!=null) {
            entry.value = value;
        } else {
            entry = new Map.Entry(key, value);
            this._entries[this._entries.length] = entry;
        }
    }
    
    Map.prototype.size = function() {
        return this._entries.length;
    }
    
    Map.prototype.getEntry = function(key) {
        for (var i=0; i<this._entries.length; i++) {
            if (this._entries[i].key==key)
                return this._entries[i];
        }
        return null;
    }
    
    Map.prototype.entries = function() {
        return this._entries;
    }
    
    Map.prototype.keys = function() {
        var result = new Array();
        for (var i=0; i<this._entries.length; i++) {
            result[result.length] = this._entries[i].key;
        }
        return result;
    }
    
    Map.prototype.values = function() {
        var result = new Array();
        for (var i=0; i<this._entries.length; i++) {
            result[result.length] = this._entries[i].value;
        }
        return result;
    }
    
    Map.prototype.addAll = function(map) {
        if (map==null)
            return;
        var oe = map.entries();
        for (var i=0; i<oe.length; i++) {
            this.put(oe[i].key, oe[i].value);
        }
    }
    
    Map.prototype.toString = function() {
        return "[Map{size:"+this._entries.length+", entries:"+this._entries+"}]";
    }
    
    Map.Entry = function(key, value) {
        if (arguments.length==0)
            return;
        this.key = key;
        this.value = value;
    }
    
    Map.Entry.prototype.toString = function() {
        return "[Entry{key:"+this.key+", value:"+this.value+"}]";
    }

    То что любой объект и так работает как Map автор видимо не знал.
    Можно было бы предположить, что автор это знал, но написал этот Map для того чтобы использовать произвольные объекты как ключи, однако во всех обнаруженных использованиях этой Map ключами были строки.

    borka, 17 Июля 2010

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

    −378

    1. 1
    2. 2
    3. 3
    4. 4
    ПЦ = 0;
    	Пока ПЦ<10000 Цикл
    		ПЦ = ПЦ + 1;
    	КонецЦикла;

    1С 7.7 Регламентированные отчеты за 2 квартал 2010 года, "декларация НДС"
    Зачем эта вставка, не понятно, может что бы помедленней работало?

    roavenik, 08 Июля 2010

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function mysql_prep($value)
    {
        if(get_magic_quotes_gpc()){
            $value = stripslashes($value);
        } else {
            $value = addslashes($value);
        }
        return $value;
    }

    "Heres a hassle free function to use to check your query string and before its handed to the db. It will add/remove slashes according to the get_magic_quotes_gpc state"

    http://lt.php.net/manual/en/function.addslashes.php

    Cyanide, 02 Июля 2010

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