1. Си / Говнокод #8397

    +110

    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
    switch (x)
    if (z == 5)
    {
        case 10:
            y = 1;
    }
    else
    {
        case 11:
            if (z > 10)
                y = 2;
            else
            {
                default:
                    y = 3;
            }
    }

    Недавно показали вот такой вот switch.
    Первое, что пришло в голову: "wtf?! это ведь даже не скомпилится".
    Я оказался не прав.

    govnopetya, 02 Ноября 2011

    Комментарии (72)
  2. PHP / Говнокод #8396

    +151

    1. 1
    2. 2
    3. 3
    for ($i = 0, $cnt = count($arList); $i < $cnt; $i++) {
    		$arConfig["CONFIG"]["category"]["VALUES"][$arList[$i]] = GetMessage('SALE_DH_RUSSIANPOST_CONFIG_CATEGORY_'.$arList[$i]);
    }

    ... вместо человеческого foreach($arList as $k => $v) { ... }

    Iceman, 02 Ноября 2011

    Комментарии (18)
  3. ActionScript / Говнокод #8395

    −112

    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
    _friend_.D2.mc_LOJKA.gotoAndStop(_friend_.D2.mc_LOJKA._totalframes) 
      if (FR_GETKEY(64) == "A") {_friend_.D2.mc_LOJKA.gotoAndStop(1)}
      if (FR_GETKEY(352) == "A") {_friend_.D2.mc_LOJKA.gotoAndStop(2)}
      if (FR_GETKEY(356) == "A") {_friend_.D2.mc_LOJKA.gotoAndStop(3)}
      if (FR_GETKEY(363) == "A") { _friend_.D2.mc_LOJKA.gotoAndStop(4) }
      if (FR_GETKEY(353) == "A") {_friend_.D2.mc_LOJKA.gotoAndStop(4)}
     _friend_.D2.mc_TARELKI.gotoAndStop(_friend_.D2.mc_TARELKI._totalframes) 
      if (FR_GETKEY(5) == "A") {_friend_.D2.mc_TARELKI.gotoAndStop(1)}
      if (FR_GETKEY(4) == "A") {_friend_.D2.mc_TARELKI.gotoAndStop(2)}
      if (FR_GETKEY(3) == "A") {_friend_.D2.mc_TARELKI.gotoAndStop(3)}
     _friend_.D4.mc_BUTILKA.gotoAndStop(_friend_.D4.mc_BUTILKA._totalframes) 
      if (FR_GETKEY(42) == "A") {_friend_.D4.mc_BUTILKA.gotoAndStop(1)}
      if (FR_GETKEY(43) == "A") {_friend_.D4.mc_BUTILKA.gotoAndStop(2)}
      if (FR_GETKEY(44) == "A") {_friend_.D4.mc_BUTILKA.gotoAndStop(3)}
     _friend_.D4.mc_NEPROLIVAIKA.gotoAndStop(_friend_.D4.mc_NEPROLIVAIKA._totalframes) 
      if (FR_GETKEY(357) == "A") {_friend_.D4.mc_NEPROLIVAIKA.gotoAndStop(1)}
      if (FR_GETKEY(26) == "A") {_friend_.D4.mc_NEPROLIVAIKA.gotoAndStop(2)}
     _friend_.D4.mc_SOSKA.gotoAndStop(_friend_.D4.mc_SOSKA._totalframes) 
      if (FR_GETKEY(40) == "A") {_friend_.D4.mc_SOSKA.gotoAndStop(1)}
      if (FR_GETKEY(38) == "A") {_friend_.D4.mc_SOSKA.gotoAndStop(2)}
      if (FR_GETKEY(37) == "A") {_friend_.D4.mc_SOSKA.gotoAndStop(3)}
     _friend_.D4.mc_ERSHIK.gotoAndStop(_friend_.D4.mc_ERSHIK._totalframes) 
      if (FR_GETKEY(121) == "A") {_friend_.D4.mc_ERSHIK.gotoAndStop(1)}
     _friend_.D5.mc_NAGRUDNIK.gotoAndStop(_friend_.D5.mc_NAGRUDNIK._totalframes) 
      if (FR_GETKEY(362) == "A") {_friend_.D5.mc_NAGRUDNIK.gotoAndStop(1)}
     _friend_.D5.mc_TERMOS.gotoAndStop(_friend_.D5.mc_TERMOS._totalframes) 
      if (FR_GETKEY(46) == "A") {_friend_.D5.mc_TERMOS.gotoAndStop(1)}
     _friend_.D7.F47.gotoAndStop(_friend_.D7.F47._totalframes) 
      if (FR_GETKEY(47) * 1 > 0) { _friend_.D7.F47.gotoAndStop(1); _friend_.D7.F47.NUM.gotoAndStop(FR_GETKEY(47)*1)}
     _friend_.D7.F50.gotoAndStop(_friend_.D7.F50._totalframes) 
      if (FR_GETKEY(50) * 1 > 0) { _friend_.D7.F50.gotoAndStop(1);_friend_.D7.F50.NUM.gotoAndStop(FR_GETKEY(50)*1)}
     _friend_.D7.F49.gotoAndStop(_friend_.D7.F49._totalframes) 
      if (FR_GETKEY(49) * 1 > 0) { _friend_.D7.F49.gotoAndStop(1);_friend_.D7.F49.NUM.gotoAndStop(FR_GETKEY(49)*1)}
     _friend_.D7.F48.gotoAndStop(_friend_.D7.F48._totalframes) 
      if (FR_GETKEY(48) * 1 > 0) { _friend_.D7.F48.gotoAndStop(1); _friend_.D7.F48.NUM.gotoAndStop(FR_GETKEY(48)*1)}
     _friend_.D8.F17.gotoAndStop(_friend_.D8.F17._totalframes) 
      if (FR_GETKEY(17) * 1 > 0) { _friend_.D8.F17.gotoAndStop(1);_friend_.D8.F17.NUM.gotoAndStop(FR_GETKEY(17) * 1)}
     _friend_.D8.F61.gotoAndStop(_friend_.D8.F61._totalframes) 
      if (FR_GETKEY(61) * 1 > 0) { _friend_.D8.F61.gotoAndStop(1);_friend_.D8.F61.NUM.gotoAndStop(FR_GETKEY(61)*1)}
     _friend_.D8.F62.gotoAndStop(_friend_.D8.F62._totalframes) 
      if (FR_GETKEY(62) * 1 > 0) { _friend_.D8.F62.gotoAndStop(1);_friend_.D8.F62.NUM.gotoAndStop(FR_GETKEY(62)*1)}
     _friend_.D8.F20.gotoAndStop(_friend_.D8.F20._totalframes) 
      if (FR_GETKEY(20) * 1 > 0) { _friend_.D8.F20.gotoAndStop(1);_friend_.D8.F20.NUM.gotoAndStop(FR_GETKEY(20)*1)}
     _friend_.D8.F19.gotoAndStop(_friend_.D8.F19._totalframes) 
      if (FR_GETKEY(19) * 1 > 0) { _friend_.D8.F19.gotoAndStop(1);_friend_.D8.F19.NUM.gotoAndStop(FR_GETKEY(19)*1)}
     _friend_.D8.F18.gotoAndStop(_friend_.D8.F18._totalframes) 
      if (FR_GETKEY(18) * 1 > 0) { _friend_.D8.F18.gotoAndStop(1);_friend_.D8.F18.NUM.gotoAndStop(FR_GETKEY(18)*1)}
     _friend_.D9.F25.gotoAndStop(_friend_.D9.F25._totalframes) 
      if (FR_GETKEY(25) * 1 > 0) { _friend_.D9.F25.gotoAndStop(1);_friend_.D9.F25.NUM.gotoAndStop(FR_GETKEY(25)*1)}
     _friend_.D10.F24.gotoAndStop(_friend_.D10.F24._totalframes)

    И еще 200 строк продолжения за кадром.

    kyzi007, 02 Ноября 2011

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

    +153

    1. 1
    http://www.gamedev.ru/flame/forum/?id=154244

    Новый язык программирования.

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

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

    +125

    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
    /// <summary>
    		/// Конвертирование String - Decimal
    		/// </summary>
    		/// <param name="text"></param>
    		/// <param name="value"></param>
    		/// <returns></returns>
    		public static decimal GetDecimal(this string text)
    		{
    			decimal number;
    			CultureInfo culture = null;
    
    			if (String.IsNullOrEmpty(text))
    				throw new ArgumentNullException("The input string is invalid.");
    
    			try
    			{
    				culture = CultureInfo.CurrentCulture;
    				number = decimal.Parse(text, culture);
    				return number;
    			}
    			catch
    			{
    			}
    
    			try
    			{
    				culture = culture.Parent;
    				number = decimal.Parse(text, culture);
    				return number;
    			}
    			catch
    			{
    			}
    
    			culture = CultureInfo.InvariantCulture;
    			try
    			{
    				number = decimal.Parse(text, culture);
    				return number;
    			}
    
    			catch (FormatException e)
    			{
    				throw new FormatException(String.Format("Unable to parse '{0}'.", text), e);
    			}
    		}

    Это финиш.

    fr0mrus, 02 Ноября 2011

    Комментарии (2)
  6. SQL / Говнокод #8392

    −108

    1. 1
    select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(t1.PART_NUMBER, '@i@', ' '),'@a@', '/'),'@@@', '\'),'@b@', ':'),'@c@', '*'),'@d@', '?'),'@e@', '"'),'@f@', '<'),'@g@', '>'),'@h@', '|'),'@j@', '&'),'@k@', ''''),'@l@', ',') as 'PART_NUMBER',.....

    edalalaeva, 02 Ноября 2011

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

    +132

    1. 1
    (#~m=^(?:GET|POST|HEAD) /.*?\r\n[Hh][Oo][Ss][Tt]: ([\w-.:]{3,100})\r\n=s

    Часть серверного приложения на Lisp. Я лично нихрена не понял, возможно не прав.

    FanAs45809, 01 Ноября 2011

    Комментарии (6)
  8. Ruby / Говнокод #8390

    −109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    command = gets.chomp
    while command != 'ПОКА'
    	if command != command.upcase
    		puts 'АСЬ?! ГОВОРИ ГРОМЧЕ, ВНУЧЕК!'
    	else
    		puts 'НЕТ, НИ РАЗУ С 1938 ГОДА!'
    	end
    end
    puts 'ПОКА, ВНУЧЕК!'

    Нашёл ошибку, лишь когда вписывал код сюда.
    Бесконечный цикл, как видите.

    nbvec222, 01 Ноября 2011

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

    +130

    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
    public void ExportOrderDetails()
            {
                char comma = ',';
                StringBuilder sb = new StringBuilder();
                string line = "";
    
                line += "Order No" + comma;
                line += "Customer" + comma;
                line += "Order Date" + comma;
                line += "Order Status" + comma;
                line += "Subtotal" + comma;
                line += "Tax Total" + comma;
                line += "Shipping Cost" + comma;
                line += "Shipping Method" + comma;
                line += "Order Total" + comma;
                line += "Payment Method" + comma;
                line += "Total Quantity" + comma;
                line += "Date Shipped" + comma;
                line += "Tracking No" + comma;
                line += "Order Currency Code" + comma;
                line += "Exchange Rate" + comma;
                line += "Billing First Name" + comma;
                line += "Billing Last Name" + comma;
                line += "Billing Company" + comma;
                line += "Billing Address" + comma;
                line += "Billing Address 2" + comma;
                line += "Billing City" + comma;
                line += "Billing Zip" + comma;
                line += "Billing State Code" + comma;
                line += "Billing Country ISO2" + comma;
                line += "Billing Phone" + comma;
                line += "Billing Phone 2" + comma;
                line += "Billing Email" + comma;
                line += "Shipping First Name" + comma;
                line += "Shipping Last Name" + comma;
                line += "Shipping Company" + comma;
                line += "Shipping Address" + comma;
                line += "Shipping Address 2" + comma;
                line += "Shipping City" + comma;
                line += "Shipping Zip" + comma;
                line += "Shipping State Code" + comma;
                line += "Shipping Country ISO2" + comma;
                line += "Shipping Phone" + comma;
                line += "Shipping Phone 2" + comma;
                line += "Shipping Email" + comma;
    
                line += "Combined Product Weight" + comma;
                line += "Product Qty" + comma;
                line += "Product SKU" + comma;
                line += "Product Name" + comma;
                line += "Product Variation Details" + comma;
                line += "Product Unit Price" + comma;
                line += "Product Unit Cost" + comma;
                line += "Product Weight" + comma;
                line += "Product Total Price" + comma;
                line += "Product Total Cost" + comma;
    
    
    
                sb.AppendLine(line.Remove(line.Length - 1));
     
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", "attachment; filename=orders-details-" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv");
                Response.ContentEncoding = Encoding.Default;
                Response.Write(sb.ToString());
                Response.End();
    
            }

    Норм так)

    sergfreest, 01 Ноября 2011

    Комментарии (5)
  10. 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)