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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. JavaScript / Говнокод #3745

    +172

    1. 1
    function getCodeByCode(code)

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

    mozg_raka, 20 Июля 2010

    Комментарии (12)
  5. Си / Говнокод #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)
  6. 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)
  7. 1C / Говнокод #3668

    −378

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

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

    roavenik, 08 Июля 2010

    Комментарии (12)
  8. 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)
  9. C++ / Говнокод #3610

    +165

    1. 1
    throw new std::bad_alloc();

    У нас в кодеконвеншене принято передавать исключения по указателю. Вчера обнаружил вот это во многих перегрузках оператора new, да и в прочих местах по проекту.

    Говногость, 01 Июля 2010

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

    −874

    1. 1
    SELECT created_at, updated_at FROM user_childs WHERE `id`=.......

    убейте меня за таймштамп user_childs.crated_at

    piroman171, 30 Июня 2010

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

    +151

    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
    function datRus ($dat) 
       {  $day = substr($dat, 8, 2); 
          $mon = substr($dat, 5, 2);
          $year= substr($dat, 0, 4); 
          switch ($mon) 
          {     case 1:  $month='Января'; break;
                case 2:  $month='Февраля'; break; 
                case 3:  $month='Марта'; break; 
                case 4:  $month='Апреля'; break; 
                case 5:  $month='Мая';  break; 
                case 6:  $month='Июня'; break; 
                case 7:  $month='Июля'; break; 
                case 8:  $month='Августа'; break; 
                case 9:  $month='Сентября'; break; 
                case 10: $month='Октября'; break; 
                case 11: $month='Ноября'; break; 
                case 12: $month='Декабря'; break; 
                default: $month=$mon;     break;
          }      
          $str = $day.' '.$month.' '.$year;
          return $str;        
       }

    Преобразование даты из mysql формата :)

    frexin, 18 Июня 2010

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