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

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

    +144.8

    1. 1
    2. 2
    3. 3
    <?
    echo $i++ + ++$i;
    ?>

    rvn, 19 Апреля 2010

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

    +149.8

    1. 1
    if( preg_match("#list(/$|$)#is", $requestUri) )

    Человек никогда не слышал про квантификаторы в регулярных выражениях.

    anei, 15 Апреля 2010

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

    +154.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    //Таблица для пароля администратора
    mysql_query("CREATE TABLE $admintable (
    ID SMALLINT UNSIGNED NOT NULL auto_increment,
    pass VARCHAR(30) NOT NULL,
    PRIMARY KEY(ID)
    )");
    
    mysql_query("INSERT INTO $admintable (pass) VALUES ('')");

    оригинальный способ хранения пароля администратора в системе nevius

    breathe, 15 Апреля 2010

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

    +74.2

    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
    package efi.base.business.metadata;
    
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    
    public class MetaModel {
        private String name = null;
        private List attributeNames = new ArrayList();
        private List attributeValues = new ArrayList();
    
        public MetaModel(String name) {
            this.name = name;
        }
    
        public String getName() {
            return name;
        }
    
        public void addAttribute(Attribute attribute) {
            attributeNames.add(attribute.getName());
            attributeValues.add(attribute);
        }
    
        public Attribute getAttribute(String attrubuteName) {
            return (Attribute) attributeValues.get(attributeNames.indexOf(attrubuteName));
        }
    
        public Iterator attributesIterator() {
            return attributeNames.iterator();
        }
    }

    Человек, писавший этот говнокласс, видимо и не подозревал, что в JDK кроме листов есть еще и Map-ы :-)

    Andronix, 14 Апреля 2010

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

    −140.6

    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
    from random import randint
    import sys
    import re
    
    
    def recupIP():
        s = r"(%s)" % ("\.".join(['(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)']*4))
        patt = re.compile(s)
        fn = "ip.txt"
        s = open(fn).read()
        i = 0
        global permulist
        permulist = []
        global recuplist
        recuplist = []
        while True:
            m = patt.search(s, i)
            if m:
                recuplist.append(m.group(1))          
                i = m.end()+1
            else:
                break
        
    #########convertir decimal au binaire###########
    
    def decimalbinaire(string):
        quotient=int(string)
        liste=[]
        global res
        res=""
        
        if quotient==0:
            res="00000000"
        else:
            while quotient!=1:
                liste=liste+[quotient%2]
                quotient=quotient/2
            liste=liste+[1]
            while liste!=[]:
                res=res+str(liste[-1])
                liste=liste[:-1]
            if len(res)<8:
                octet=8-len(res)
                res='0'*octet + res
        return res
    recupIP()
    
    z = 0
    binip,convert = [],[]
    i=0
    while i < len(recuplist):
    	string = str(recuplist[i])
    	string = string.split(".")
    	while z < len(string):
    		decimalbinaire(string[z])
    		binip.append(res)
    		z = z + 1
    	binip="".join(binip)
            convert.append(binip)
            i=i+1

    Насколько я понял из условия того кто это делал - программа должна брать список IP-адресов, конвертить их в бинарный формат и затем, сохраняя формат, создавать новый список.
    Реализацию я до конца понять не смог.

    Nook, 11 Апреля 2010

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

    +144.8

    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
    #ifndef __gen_spi_h
    #define __gen_spi_h
    
    #ifndef SPI_PORT_TYPE_OVERRIDE
    #define SPI_PORT_TYPE unsigned int
    #endif
    
    #ifndef SPI_BYTE_TYPE_OVERRIDE
    #define SPI_BYTE_TYPE unsigned char 
    #endif
    
    // SPI SS SIGNAL --- OUT
    #define DECL_SS(N, P, B) \
    volatile SPI_PORT_TYPE *const _##N##_SS_POUT = &(P##OUT); \
    volatile SPI_PORT_TYPE *const _##N##_SS_PDIR = &(P##DIR); \
    const SPI_PORT_TYPE           _##N##_SS_BIT  = B
    
    // SPI SCK SIGNAL --- OUT
    #define DECL_SCK(N, P, B) \
    volatile SPI_PORT_TYPE *const _##N##_SCK_POUT = &P##OUT; \
    volatile SPI_PORT_TYPE *const _##N##_SCK_PDIR = &(P##DIR); \
    const SPI_PORT_TYPE           _##N##_SCK_BIT  = B
    
    // SPI MOSI SIGNAL --- OUT
    #define DECL_MOSI(N, P, B) \
    volatile SPI_PORT_TYPE *const _##N##_MOSI_POUT = &P##OUT; \
    volatile SPI_PORT_TYPE *const _##N##_MOSI_PDIR = &P##DIR; \
    const SPI_PORT_TYPE           _##N##_MOSI_BIT  = B
    
    // SPI MISO SIGNAL --- IN
    #define DECL_MISO(N, P, B) \
    volatile SPI_PORT_TYPE *const _##N##_MISO_PIN  = &P##IN; \
    volatile SPI_PORT_TYPE *const _##N##_MISO_PDIR  = &P##DIR; \
    const SPI_PORT_TYPE           _##N##_MISO_BIT  = B
    
    #define SETSS(N) *(_##N##_SS_POUT) |= _##N##_SS_BIT
    #define CLRSS(N) *(_##N##_SS_POUT) &= ~(_##N##_SS_BIT)
    
    #define SETMOSI(N) *(_##N##_MOSI_POUT) |= _##N##_MOSI_BIT
    #define CLRMOSI(N) *(_##N##_MOSI_POUT) &= ~(_##N##_MOSI_BIT)
    
    #define SETCLK(N) *(_##N##_SCK_POUT) |= _##N##_SCK_BIT
    #define CLRCLK(N) *(_##N##_SCK_POUT) &= ~(_##N##_SCK_BIT)
    
    #define READMISO(N) (((*(_##N##_MISO_PIN)) & _##N##_MISO_BIT) != 0)
    
    #define SPI_SETUP(N) \
        SETSS(N); \
       *(_##N##_SCK_PDIR)  |= _##N##_SCK_BIT;     \
       *(_##N##_MOSI_PDIR) |= _##N##_MOSI_BIT;    \
       *(_##N##_SS_PDIR)   |= _##N##_SS_BIT;      \
       *(_##N##_MISO_PDIR) &= ~(_##N##_MISO_BIT); \
        CLRSS(N); \
        SETSS(N)
    
    #define DECL_SPI_TRANS_BYTE(N) \
    SPI_BYTE_TYPE _##N##_spi_trans_byte(SPI_BYTE_TYPE val) { \
      register SPI_BYTE_TYPE bitnum; \
      for (bitnum = 0; bitnum < 8; bitnum++) { \
        if (val & 0x80) SETMOSI(N); \
        else CLRMOSI(N); \
        val <<= 1; \
        SETCLK(N); \
        val |= READMISO(N); \
        CLRCLK(N); \
      } \
      return val; \
    } \
    
    #define SPI_BEGIN(N) SETSS(N);CLRSS(N)
    #define SPI_END(N)   SETSS(N)
    
    #define SPI_TRANS_BYTE(N, B) _##N##_spi_trans_byte((B))
    
    #endif

    dmzlj.livejournal.com, 10 Апреля 2010

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

    −143.2

    1. 1
    2. 2
    3. 3
    4. 4
    # Это не баш, это cmd.exe, просто в ListBox'e нет интерпретатора Винды, что намекает как бы, но коль родственно немного
    # тем более покажемс Вам POSIX Винды
    
    SET a1 = [time /T] && SET b1 = [\time.%a1%.tmp] && whoami /all > %b1% && notepad %b1% && edit %b1%

    Это не баш, это cmd.exe, просто в ListBox'e нет интерпретатора Винды, что намекает как бы, но коль родственно немного, тем более покажемс Вам POSIX Винды.

    sergylens, 06 Апреля 2010

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

    +122.6

    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
    string[] mas_param = a.Split('_');
                this.s_sw_neraspred = mas_param[15];
                s_neraspred.Text = this.s_sw_neraspred;
                int i = a.IndexOf("_", 0, a.Length);
                sw_id = a.Substring(0, i);
                int j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                mf_id = a.Substring(j, i - j);
                //mf1=a.Substring(j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                ta_ed = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                this.s_op = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_rm = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_tm = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_sw = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                ta_sd = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                sw_sd = a.Substring(j, i - j);
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                sw_ed = a.Substring(j, i - j);
                //mf_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                mf_topsw = a.Substring(j, i - j);
                //s_op_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_op_topsw = a.Substring(j, i - j);
                //s_rm_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_rm_topsw = a.Substring(j, i - j);
                //s_tm_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_tm_topsw = a.Substring(j, i - j);
                //s_sw_topsw
                j = i + 1;
                i = a.IndexOf("_", j, a.Length - j);
                s_sw_topsw = a.Substring(j, i - j);            
            
    
                //ta
    
                ta_id = a.Split('_')[mas_param.Length-1];

    a - строка вида
    {0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_ {10}_{11}_{12}_{13}_{14}_{15}_{16}

    alex_donetsk, 01 Апреля 2010

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

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    char str[STR_LEN + 1]; 
    
    strncpy(str, inpust_str, STR_LEN);
    xxx[STR_LEN] = '\0';
    
    str[ strlen(str) ] = ':';
    str[ strlen(str) + 1 ] = '1';
    str[ strlen(str) + 2 ] = '\0';

    Попытка добавить ":1" к строке.

    Первым же "str[ strlen(str) ] = ':';" гробим нулевой символ в конце строки. Дальнейшие вызовы "strlen" - просто фигня какая-то. Ну и портим память.

    benderlog, 23 Марта 2010

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

    +152.6

    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
    function str_replace ( search, replace, subject ) {	// Replace all occurrences of the search string with the replacement string
    	// 
    	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    	// +   improved by: Gabriel Paderni
    
    	if(!(replace instanceof Array)){
    		replace=new Array(replace);
    		if(search instanceof Array){//If search	is an array and replace	is a string, then this replacement string is used for every value of search
    			while(search.length>replace.length){
    				replace[replace.length]=replace[0];
    			}
    		}
    	}
    
    	if(!(search instanceof Array))search=new Array(search);
    	while(search.length>replace.length){//If replace	has fewer values than search , then an empty string is used for the rest of replacement values
    		replace[replace.length]='';
    	}
    
    	if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
    		for(k in subject){
    			subject[k]=str_replace(search,replace,subject[k]);
    		}
    		return subject;
    	}
    
    	for(var k=0; k<search.length; k++){
    		var i = subject.indexOf(search[k]);
    		while(i>-1){
    			subject = subject.replace(search[k], replace[k]);
    			i = subject.indexOf(search[k],i);
    		}
    	}
    
    	return subject;
    
    }

    function str_replace(search, replace, subject) { return subject.split(search).join(replace);}

    DrFreez, 22 Марта 2010

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