1. Assembler / Говнокод #78

    −248

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    nop
    nop
    nop
    call somelabel
    somelabel:
    pop si
    sub si, 3

    ассемблер - источник массы говнокода, классика...

    guest, 08 Декабря 2008

    Комментарии (27)
  2. JavaScript / Говнокод #77

    +22.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
    var newstr = null;
    		var lastnewstr = null;
    		var newclass = null;
    		var lastclass = null;
    		var newstr2 = null;
    		var lastnewstr2 = null;
    		var newclass2 = null;
    		var lastclass2 = null;
    		var newstr3 = null;
    		var lastnewstr3 = null;
    		var newclass3 = null;
    		var lastclass3 = null;
    		
    function check(s, i)
    {
    		p1 = document.getElementById("id_1_"+i);
    		p2 = document.getElementById("id_2_"+i);
    	if (s!=lastnewstr)
    	{
    		newclass2 = p1.className;
    		newclass3 = p2.className;
    		newclass = s.className;
    		s.className="check";
    		p1.className="viz";
    		p2.className="viz";
    		if (lastnewstr!=null)
    		{
    			lastnewstr.className=lastclass;
    			lastnewstr2.className=lastclass2;
    			lastnewstr3.className=lastclass3;
    		}
    	}
    	lastnewstr = s;
    	lastnewstr2 = p1;
    	lastnewstr3 = p2;
    	lastclass = newclass;
    	lastclass2 = newclass2;
    	lastclass3 = newclass3;
    }

    Убожество которое на одной строке меняет у <tr> стиль и еще у двух элементов...

    guest, 08 Декабря 2008

    Комментарии (0)
  3. Java / Говнокод #76

    −32.7

    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
    public void updateAmountValues(List<TransactionResultItem> transactionResultItems) {
            for (TransactionResultItem transaction : transactionResultItems) {
                Account account = getAccountById(transaction.getAccountId());
                if ((transaction.getMainTransaction()
                        && ! transaction.getTransactionTypeId().equals(4)
                        && ! transaction.getTransactionTypeId().equals(5)
                        && ! transaction.getTransactionTypeId().equals(6))
                        ||
                        (! transaction.getMainTransaction() &&
                                (transaction.getTransactionTypeId().equals(5) &&
                                        ((account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                                account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                                transaction.getAmount() > 0)
                                        || (transaction.getAccountId().equals(getSalesTaxPayableAccountId()) && transaction.getAmount() > 0)
                                        || ((account.getAccountTypeId().equals(AccountType.EXPENSE_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_EXPENSE_TYPE_ID)) && transaction.getAmount() < 0))
                                || (transaction.getTransactionTypeId().equals(1) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() < 0)
                                || (transaction.getTransactionTypeId().equals(2) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() > 0)
                        )) {
                    Double amount = transaction.getAmount();
                    transaction.setAmount(-amount);
                }
            }
        }

    Потрясающий по понятности код. Вызывался несколько раз в одном и том же методе.

    guest, 08 Декабря 2008

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

    −53.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /**
     * Reply string array after tokenize the url address
     *
     * @param String url
     * @return String[]
     */
    protected String[] processURL(String url) {
    
        StringBuffer s = new StringBuffer(url);
        StringBuffer AfterRemoval = s.delete(0, 27);
    ...

    ...в тот день магическим числом для паренька из Индии было число 27... похоже он и сам не понимал почему.. возможно это как то было связано с именем хоста...

    guest, 08 Декабря 2008

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

    −417.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    SELECT FROM Staff
      CASE Sex
      WHEN 'M' THEN 'МужЫк!'
      WHEN 'F' THEN 'Баба'
      ELSE 'ЫЫЫыы?'

    препод сказал что елсе не будет выполняться изза ограничений целостности базы

    guest, 08 Декабря 2008

    Комментарии (5)
  6. ActionScript / Говнокод #73

    −599.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
    private function _mouseDown(e:MouseEvent):void 
    {
    	stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
    	if (e.target is PCell) {
    		//Клик по клетке, но возможно хотят подвигать поле :)
    		_startDrag(e);
    	}
    	else {
    		//Значит двигаем поле
    		_startDrag(e);
    	}
    }

    guest, 08 Декабря 2008

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

    +30

    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
    private static string identifier(string wmiClass, string wmiProperty)
                {
                    string result = "";
                    System.Management.ManagementClass mc =
                new System.Management.ManagementClass(wmiClass);
                    System.Management.ManagementObjectCollection moc = mc.GetInstances();
                    foreach (System.Management.ManagementObject mo in moc)
                    {
                        //Only get the first one
                        if (result == "")
                        {
                            try
                            {
                                result = mo[wmiProperty].ToString();
                                break;
                            }
                            catch
                            {
                            }
                        }
                    }
                    return result;
                }

    guest, 08 Декабря 2008

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

    −43.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
    private Map<Class<?>, Map<String, String[]>> compressDependencies(
          Map<Class<?>, Map<String, List<String>>> dependencies) {
        final Map<Class<?>, Map<String, String[]>> result =
            new FastMap<Class<?>, Map<String, String[]>>(dependencies.size());
        final Set<Entry<Class<?>, Map<String, List<String>>>> entrySet = dependencies.entrySet();
        for (Entry<Class<?>, Map<String, List<String>>> entry : entrySet) {
          final Map<String, List<String>> value = entry.getValue();
          final Map<String, String[]> desc = new FastMap<String, String[]>(value.size());
          final Set<Entry<String, List<String>>> subEntries = value.entrySet();
          for (Entry<String, List<String>> valueEntry : subEntries) {
            final List<String> list = valueEntry.getValue();
            if (list != null && !list.isEmpty()) {
              desc.put(valueEntry.getKey(), list.toArray(new String[list.size()]));
            }
          }
          result.put(entry.getKey(), desc);
        }
        return result;
      }

    Код от "мега разработчика", архитектора очень большого проекта.

    PS Будьте осторожны в использовании java generics :)

    guest, 08 Декабря 2008

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

    +33.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <script>
    function changeLogo(imgLoc){
        document.getElementById("module_logo").src = "./site/" + imgLoc + "_logo.jpg";
    }
    function returnLogo(imgLoc){
        document.getElementById("module_logo").src = "./site/" + imgLoc + "_logo.jpg";
    }
    </script>

    guest, 08 Декабря 2008

    Комментарии (5)
  10. PHP / Говнокод #69

    +30.6

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    $cResult = mysql_query($cQuery) or die(mysql_error());
    if (mysql_num_rows($cResult) <= 0)
    {
    	if ( $_GET['extra'] == "a" || $_GET['extra'] == 4 || $_GET['extra'] == 16 || $_GET['extra'] == "n" || $_GET['extra'] == "m" || $_GET['extra'] == "m_in_cat" )
    		{}
    	else
    		{
    		echo CAT_NO_WALP;
    		}
    } else
    {
    	$Row = mysql_fetch_object($cResult);
    	$id = $Row->id;
    
    	if ( $_GET['extra'] == "a" )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == 4 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `four_three` = '1' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == 16 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `sixteen_ten` = '1' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == "n" )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `status_NEW` = '1' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == "m" )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == "m_in_cat" )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC");
    		}
    	else
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");   ///-------------
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC");
    		}
    
    	if ( $_GET['extra'] == "a" && $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == 4 && $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `four_three` = '1' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == 16 && $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `sixteen_ten` = '1' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == "n" && $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `status_NEW` = '1' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == "m" && $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC");
    		}
    	elseif ( $_GET['extra'] == "m_in_cat" && $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC");
    		}
    	elseif ( $_SESSION['usergroupid'] > 3	elseif ( $_SESSION['usergroupid'] > 3 )
    		{
    		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");   ///-------------
    		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
    		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC");
    // И еще примерно столько же подобного говнеца. Сюда просто не влазит...
    	}

    Пустые ифы, куча лишних запросов.
    Очень яркий пример ИНДУСтриального программирования.

    guest, 08 Декабря 2008

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