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

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

    +125.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
    function CheckBankAccount(BIK, _Account) {
        var Mask = "71371371371371371371371";
        var Control = 0;
        var M;
        var strM;
    
        if (!BIK) {
            return true;
        }
    
        var Account = BIK.substring(6, 9) + _Account;
    
        for (var i = 0; i <= 22; i++) {
            M = RealParseInt(Account.substring(i, i+1))*RealParseInt(Mask.substring(i, i+1));
            strM = M.toString();
            Control += RealParseInt(strM.substring(strM.length-1, strM.length));
        }
    
        var R = ((Control/10) - Math.floor(Control/10));
    
        if (R == 0) {
            return true;
        }
        else {
            return false;
            }
    }

    Существует множество способов взять остаток от деления на 10. Два из них в этом примере...

    guest, 24 Апреля 2009

    Комментарии (2)
  3. Pascal / Говнокод #934

    +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
    if kol=1 then begin
     if GSravn.Cells[kol,Str]='VF'
                then GSravn.Cells[kol,Str]:='RF'
                else if GSravn.Cells[kol,Str]='RF'
                        then GSravn.Cells[kol,Str]:='PF'
                        else if GSravn.Cells[kol,Str]='PF'
                                then GSravn.Cells[kol,Str]:='PT'
                                else if GSravn.Cells[kol,Str]='PT'
                                        then GSravn.Cells[kol,Str]:='RT'
                                        else if GSravn.Cells[kol,Str]='RT'
                                                then GSravn.Cells[kol,Str]:='VT'
                                                else if GSravn.Cells[kol,Str]='VT'
                                                        then GSravn.Cells[kol,Str]:='VF';

    %)

    guest, 23 Апреля 2009

    Комментарии (2)
  4. C# / Говнокод #909

    +113.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public object DeepCopy(object value)
            {
                try
                {
                    return value;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

    такой код повсюду... Источник: http://ayende.com/Blog/archive/2009/04/13/there-are-so-many-things-wrong-with-this-codehellip.aspx

    guest, 21 Апреля 2009

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    if($a==1){
    $a = 1;
    return $a
    }

    Вот что прислали индусы!

    guest, 19 Апреля 2009

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

    +150

    1. 1
    FALSE === $cache || 0 == (int)$cache

    пиздец. класс dbtree.

    guest, 19 Апреля 2009

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

    +100.3

    1. 1
    2. 2
    3. 3
    4. 4
    public Date getAddedDate(Date date, int interval) {
        String sql = "select DATE_ADD('" + date + "', INTERVAL " + interval + " DAY)";
        return (Date) jdbc.queryForObject(sql, Date.class);
    }

    Добавление определенного количества дней к заданной дате. Как это сделать? Конечно c помощью SQL :)

    guest, 17 Апреля 2009

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

    +172.1

    1. 1
    2. 2
    3. 3
    #pragma warning( disable : 4005 )
    #define TRUE free(reinterpret_cast<VOID*>(-1))
    #pragma warning( default : 4005 )

    merry debugging!
    (return TRUE; :)

    guest, 17 Апреля 2009

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

    +147.3

    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
    $foo = "";
    $l = strlen($testoBanner);
    for($i=0; $i<$l; $i++) {
    	$t = substr($testoBanner, $i, 1);
    				
    	if($t != "\r") {
    		if($t == "\n") {
    			//$foo .= "<br>";
    		} else {
    			$foo .= $t;	
    		}
    	}
    }
    		
    $testoBanner = $foo;

    Нашел тут свой старый код. Это я так из строки удалял \r и \n :)

    guest, 14 Апреля 2009

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

    +151

    1. 1
    2. 2
    3. 3
    if (null == ids || (null != ids && !ids.isEmpty())) {
    	requests = dao.getMyAnsweredRequests(userId, firstResult, maxResults, ids);
    }

    Выполняеться в любом случае

    guest, 14 Апреля 2009

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

    +171.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(isset($_POST['username']) and isset($_POST['password'])) {
               $user = $_POST['username'];
               $pass = $_POST['password'];
    
               if($user == $pass) {
                       $_SESSION['user'] = $user;
                       $_SESSION['logged_in'] = true;
               }
       }

    классная авторизация
    оригинал http://bacula.svn.sourceforge.net/viewvc/bacula/trunk/docs/home-page/en/inc/header.php?revision=8397&view=markup

    guest, 14 Апреля 2009

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