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

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

    −94

    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
    ' ==== Пример №1 ====
    strParentAsset = "Parent_Asset_OnetoOneRelationship_Child_NewEarlyStaged"
    strChildAsset = "ChildAssetArray_NewEarlyStaged"
    strArrAssetList = Split(strParentAsset & "," & strChildAsset, ",")
    
    ' ==== Пример №2 ====
    strProjectNames="" & strTODO_Project & "1," & strTODO_Project & "2," & strTODO_Project & "3," & strTODO_Project & "4," & strTODO_Project & "5," & strTODO_Project & "6," & strTODO_Project & "7," & strTODO_Project & "8," & strTODO_Project & "9," & strTODO_Project & "10," & strTODO_Project & "11," & strTODO_Project & "12," & strTODO_Project & "13," & strTODO_Project & "14," & strTODO_Project & "15," & strTODO_Project & "16," & strTODO_Project & "17," & strTODO_Project & "18," & strTODO_Project & "19," & strTODO_Project & "20," & strTODO_Project & "21," & strATG_TODO_PROJECT22
    strArrProjectNames= Split(strProjectNames,",")
    
    ' ==== Пример №3 ====
    Dim strWeekday
    ...
    ReDim strWeekday(7)
    strWeekday(1)= "Sun":strWeekday(2)= "Mon":strWeekday(3)= "Tue":strWeekday(4)= "Wed":strWeekday(5)= "Thu":strWeekday(6)= "Fri":strWeekday(7)= "Sat"

    Примеры создания массивов из QTP-проекта, написанного индусами

    Lurker, 16 Ноября 2011

    Комментарии (4)
  3. Куча / Говнокод #8501

    +150

    1. 1
    http://www.gamedev.ru/users/?id=45914

    AnimeGovno-_-, 12 Ноября 2011

    Комментарии (4)
  4. Java / Говнокод #8463

    +70

    1. 1
    2. 2
    3. 3
    4. 4
    @Override protected void finalize()
    {
        Runtime.addShutdownHook();
    }

    Здесь без комментариев...

    dwinner, 09 Ноября 2011

    Комментарии (4)
  5. JavaScript / Говнокод #8444

    +160

    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
    if (parseInt(navigator.appVersion)>3)
                {
                    if (navigator.appName=="Netscape")
                    {
                        winW = window.innerWidth;
                        winH = window.innerHeight;
                    }
                    if (navigator.appName.indexOf("Microsoft")!=-1)
                    {
                        winW = document.documentElement.offsetWidth;
                        winH = document.documentElement.offsetHeight;
                    }
                }

    daymansiege, 07 Ноября 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /**
     * Удаление почтового индекса из строки адреса
     * @param string $str исходный адрес
     * @return string адрес без индекса
     */
    function skip_addr_index($str) {
      return substr(strstr($str, 'Челябинск'), 14);
    }

    Автор из Челябинска :-)

    psrustik, 07 Ноября 2011

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

    +75

    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
    // Gets the starting position for the endtag of the first element in text.
        private int getEndTagPosition(String element, String text) {
            String startTag = "<" + element;
            String endTag = "</" + element;
            int nestingLevel = 1;
            int end = 0;
            int startPos = 1;
    
            while (nestingLevel > 0) { // loop until matching endtag is found
                int start = text.indexOf(startTag, startPos);
                end = text.indexOf(endTag, startPos);
    
                if ((start == -1) || (start > end)) {   // next tag is an endtag
                    nestingLevel--;
                    startPos = end + 1;
                } else {    // next tag is a starttag
                    nestingLevel++;
                    startPos = start + 1;
                }
            }
    
            return end;
        }

    euee, 03 Ноября 2011

    Комментарии (4)
  8. Java / Говнокод #8406

    +75

    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
    private Connection getConnection() throws SQLException {
    		Connection conn = null;
    		try{
    			conn = DriverManager.getConnection(OnlineUsers.db,OnlineUsers.user,OnlineUsers.pass);
    		} catch (Exception e) {
    			log.severe(name + ": " + e.getMessage());
    		}
    		checkConnection(conn);
    		return conn;
    	}
    	
    	private boolean checkConnection (Connection conn) throws SQLException {
    		if (conn == null) {
    				log.severe("Could not connect to the database. Check your credentials in online-users.settings");
    			throw new SQLException();
    		}
    		if (!conn.isValid(5)) {
            	log.severe("Could not connect to the database.");
            	throw new SQLException();
            }
    		return true;
    	}
    	
    	private boolean execute(String sql) {
    		return execute(sql, null);
    	}
    	
    	private boolean execute(String sql, String player) {
    		Connection conn = null;
            PreparedStatement ps = null;
            try {
            	conn = getConnection();
            	ps = conn.prepareStatement(sql);
            	if (player != null && !player.equalsIgnoreCase("")) {
            		ps.setString(1, player);
            	}
            	
            	if (ps.execute()) {
            		return true;
            	}
            } catch (SQLException ex) {
            	log.severe(name + ": " + ex.getMessage());
            	String msg = name + ": could not execute the sql \"" + sql + "\"";
            	if (player != null ) {
            		msg += "    ?=" +player;
            	}
            	log.severe(msg);
            } finally {
                try {
                    if (ps != null) {
                        ps.close();
                    }
                    if (conn != null) {
                        conn.close();
                    }
                } catch (SQLException ex) {
                	log.severe(name + ": " + ex.getMessage());
                }
            }
            return false;
    	}

    Мартин, 02 Ноября 2011

    Комментарии (4)
  9. Python / Говнокод #8388

    −101

    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
    def api_login() :
    	url = 'https://api.vk.com/oauth/authorize'
    	
    	values = {
    		'client_id' : '1998533',
    		'response_type' : 'token'
    		}
    	
    	headers = {
    		'User-Agent' : 'Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.9.168 Version/11.51',
    		'Cookie' : 'remixsid=' + sid
    		}
    	
    	try:
    		data = urllib.urlencode(values)
    		req = urllib2.Request(url, data, headers)
    		response = urllib2.urlopen(req)
    		res = response.read()
    		geturl = response.geturl()
    
    		if geturl != url :
    			reg = 'access_token=(.*?)&'
    			rg = re.compile(reg,re.IGNORECASE|re.DOTALL)
    			m = rg.search(geturl)
    			if m:
    				token=m.group(1)
    				print 'API: login'
    				return token
    		else :
    			reg='\?hash=(.*?)&'
    			rg = re.compile(reg,re.IGNORECASE|re.DOTALL)
    			m = rg.search(res)
    			
    			if m:
    				hash = m.group(0)
    				url = 'https://api.vk.com/oauth/grant_access'+hash+'client_id=1998533&redirect_uri=blank.html&response_type=token'
    				
    				req = urllib2.Request(url, '', headers)
    				response = urllib2.urlopen(req)
    				res = response.read()
    				geturl = response.geturl()
    
    				reg = 'access_token=(.*?)&'
    				rg = re.compile(reg,re.IGNORECASE|re.DOTALL)
    				m = rg.search(geturl)
    				if m:
    					token = m.group(1)
    					print 'API: login'
    					return token
    	except Exception, detail:
    		print "Error ", detail
    
    def api(method, values = {}) :
    	url = 'https://api.vk.com/method/' + method + '.json'
    	
    	values.update({'access_token' : token})
    
    	headers = {
    		'User-Agent' : 'Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.9.168 Version/11.51',
    		'Cookie' : 'remixsid=' + sid
    		}
    	
    	try:
    		data = urllib.urlencode(values)
    		req = urllib2.Request(url, data, headers)
    		response = urllib2.urlopen(req)
    		res = response.read()
    		return res
    	except Exception, detail:
    		print "Error ", detail

    anonymouse587658967, 01 Ноября 2011

    Комментарии (4)
  10. Java / Говнокод #8387

    +75

    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
    private enum UpdateToken {
        W, A, F, D, H;
    
        private static final Pattern PATTERN = compilePattern(UpdateToken.class);
    }
    
    private static Pattern compilePattern(Class<? extends Enum> clazz) {
        StringBuilder builder = new StringBuilder("(");
        for (Enum enumConstant : clazz.getEnumConstants()) {
            if (enumConstant.ordinal() > 0) {
                builder.append("|");
            }
            builder.append(enumConstant.name());
        }
        builder.append(")");
        return Pattern.compile(builder.toString());
    }
    
    //и это добро вот так используется:
    
        if (!UpdateToken.PATTERN.matcher(token).matches()) {
            continue;
        }
        UpdateToken setupToken = UpdateToken.valueOf(token);

    https://github.com/aichallenge/aichallenge/blob/epsilon/ants/dist/starter_bots/java/AbstractSystemInputParser.java

    rat4, 01 Ноября 2011

    Комментарии (4)
  11. Pascal / Говнокод #8367

    +100

    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
    {Podschet dlini}
    Reset(f1);
    kol:=0;
    while not eof(f1) do begin
    readln(f1,l);
    For i1:=1 to length(l) do if (l[i]='a')or(l[i]='A') or (l[i]='b')or(l[i]='B')
    or(l[i]='c')or(l[i]='C')or(l[i]=' ')or(l[i]='d')or(l[i]='D')
    or(l[i]='e')or (l[i]='E') or(l[i]='f') or(l[i]='F')
    or (l[i]='g')or (l[i]='G') or (l[i]='h')or(l[i]='H')
    or(l[i]='i')or(l[i]='I')or(l[i]='J')or(l[i]='j')
    or(l[i]='k')or(l[i]='K')or(l[i]='l')or(l[i]='L')
    or (l[i]='m')or (l[i]='M')or(l[i]='n')or(l[i]='N')
    or (l[i]='o')or(l[i]='O')or(l[i]='p')or(l[i]='P')
    or(l[i]='q')or(l[i]='Q')or (l[i]='r')or (l[i]='R')
    or(l[i]='S')or(l[i]='s')or(l[i]='t')or(l[i]='T')
    or(l[i]='v')or(l[i]='V') or(l[i]='w')or(l[i]='W')
    or(l[i]='u')or(l[i]='U')or(l[i]='x')or(l[i]='X')
    or(l[i]='y')or(l[i]='Y')or (l[i]='z')or(l[i]='Z') then
    kol:=kol+1;
    end;
    WriteLn('kol=',kol);

    Необходимо создать текстовый файл, содержащий исходную программу, а также подсчитать длину созданного файла.
    http://ithappens.ru/story/7652

    d_dev, 31 Октября 2011

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