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

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

    +137

    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
    GePolygon newPoly;
    int c_ai = 0, n_pi = 0;
    int fac[GE_MAX_POLY_VERTEX];
    newPoly.n = 0;
        
    Pt diff = ccpSub(end, bgn);
        
    int f = 0;
    do
       newPoly.p[newPoly.n] = ai[c_ai] == (n_pi - 1) ? (f = 1, a[c_ai++]) : (f = 0, inp->p[n_pi++]),
       fac[newPoly.n++] = f ? 0 : (ccpCross(ccpSub(newPoly.p[newPoly.n - 1], newPoly.p[newPoly.n - 2]), diff) > 0 ? 1 : -1 );
    while(n_pi < inp->n);
    if(c_ai < ac)
       newPoly.p[newPoly.n] = a[c_ai], fac[newPoly.n++] = 0;

    Из личной коллекции. Не помню, что конкретно делает, что-то вроде классификации точек полигона относительно линии...

    tirinox, 02 Января 2013

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

    +159

    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
    var fmCategoryClass = function(fmCategory) {
                    switch (parseInt(fmCategory))
                    {
                        case 0: return 'important';
                        case 1: return 'sell';
                        case 2: return 'buy';
                        case 3: return 'exchange';
                        case 4: return 'service';
                        case 5: return 'rent';
                        case 6: return 'close';
                        default: return '';
                    }
                }

    http://onliner.by - один из самых посещаемых сайтов в Беларуси - содержит прям в вёрстке

    daemon_master, 28 Декабря 2012

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

    +102

    1. 1
    originalTransform

    final Transform starscream = root.getLocalTransform();
    final Transform skywarp = transform.clone();

    someone, 24 Декабря 2012

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    /**Not related to Cosmos and Space-ships
     * */
    public class SpaceListener {
    ...

    Просто шутка в комментарии к лисенеру нажатий пробела.

    alexcom, 18 Декабря 2012

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

    +153

    1. 1
    $("#datepicker1").datepicker("setDate", new Date((Math.round((new Date().getTime() / 1000)) - x2) * 1000));

    Из недавнего

    varg242, 18 Декабря 2012

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

    +41

    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
    # POST /register
    Public Function Register(){
        foreach((array)$_POST as $k=>$v)
            $_POST[$k] = addslashes(strip_tags($v));
        $login = $_POST['Login'];
        $password = $_POST['Password'];
        $email = $_POST['Email'];
        $firstname = $_POST['FirstName'];
        $lastname = $_POST['LastName'];
        $errors = array();
    
        IF(!Session::Restore()){
            Driver::Init();
            IF(String::is_valid_email_address($email)){
                IF(strlen($login) > 3 && strlen($login) <= 12 && String::Check('([a-zA-Z0-9_]+)', $login) ){
                    IF(strlen($password) > 5 && $password == $_POST['RePassword']){
                        $users = Collection::Get('users')->Select(Query::Equal('login', $login));
                        IF(!sizeof($users)){
                            $user = new User;
                            $user->login = strtolower($login);
                            $user->password = md5($password);
                            $user->regtime = time();
                            $photo = UploadedFiles::Get('Photo');
                            IF($photo)
                                IF($photo->exists){
                                    $photoHash = md5('photo_'.$user->login);
                                    $photosPath = APPLICATION_DIR.'/assets/uploads/photos';
                                    $photo->Path = $photosPath.'/tmp/'.$photoHash;
                                    ImageProcessing::MakeThumb($photo->Path, $photosPath.'/300/'.$photoHash.'.jpg', 100, 300, 500);
                                    ImageProcessing::MakeThumb($photo->Path, $photosPath.'/100/'.$photoHash.'.jpg', 100, 100);
                                    ImageProcessing::MakeThumb($photo->Path, $photosPath.'/50/'.$photoHash.'.jpg', 100, 50);
                                    @unlink($photo->Path);
                                    $user->photo = $photoHash;
                                }
                            $user->save();
                            Session::Link($login, $password);
                            return Router::Redirect('/profile');
                        }
                        else $errors[] = l('This username is already taken');
                    }
                    else $errors[] = l('Password length must be more than 3');
                }
                else $errors[] = l('Login length must be more than 3, and less than 13 characters and contain only Latin characters');
            }
            else $errors[] = l('Your email address must be in the format of [email protected]');
        }
        else $errors[] = l("You are already registered");
        $view = new View('main.php');
        return $view->Set('Content', 'registration.php')->Set('login', $login)->Set('email', $email)->Set('firstname', $firstname)->Set('lastname', $lastname)->Set('errors', $errors);
    }

    Ну так.

    d3n4, 14 Декабря 2012

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

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    rename-wiki:
    	$(shell cd ${WIKIDST} && rename 'i-iterate' 'Iterate' *.wiki)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/\[i-iterate/\[Iterate/g' '{}' \;)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/\.html\#/\#/g' '{}' \;)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/&lt;/\</g' '{}' \;)
    	$(shell find ${WIKIDST} -name "*.wiki" -exec \
    sed -i 's/&gt;/\>/g' '{}' \;)

    Чтоль порадовать вас чем-нибудь?

    wvxvw, 12 Декабря 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(is_dir('install')|| is_dir('migrate')) {
            if (!file_exists(PATH.'/includes/config.inc.php')){
                header('location:/install/');
    			die();
            } else {
                include(PATH.'/core/messages/installation.html');
                die();
            }
        }

    Govnisti_Diavol, 10 Декабря 2012

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

    +109

    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
    string New_naim = E.Remove(0, (NameGR(E.Trim()).Length)).Trim() + " " + Na;
                                    New_naim = New_naim.Trim();
                                    string check_naim =
                                        (E+Na).ToUpper().Replace(" ", "").Replace(",", ".").Replace("-", "").Replace("Е", "E")
                                        .Replace(";", "").Replace("*", "").Replace("Х", "X").Replace("О", "O").Replace("А", "A")
                                        .Replace("В", "B").Replace("М", "M").Replace("Н", "H").Replace("С", "C").Replace("Т", "T").Replace("З", "3")
                                        .Replace("Р", "P").Replace("Q", "G").Replace("К", "K").Replace("О", "O").Replace("0", "O").Replace("%", "").Replace("И", "U");
                                    string check_gosttu = GU.ToUpper().Replace(" ", "").Replace(",", ".").Replace("Е", "E").Replace(".", "")
                                        .Replace("З", "3").Replace(";", "").Replace("*", "").Replace("Х", "X").Replace("О", "O").Replace("А", "A")
                                        .Replace("И", "U").Replace("В", "B").Replace("М", "M").Replace("Н", "H").Replace("С", "C").Replace("Т", "T").Replace("-", "")
                                        .Replace("Р", "P").Replace("Q", "G").Replace("К", "K").Replace("О", "O").Replace("0", "O").Replace("+", "");
                                    /*quer = "SELECT PIN From dbo.Tb_Element Where (Id = '" + Id_el + "') AND "+
                                        "replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(GOSTTU)" +
                                        ",' ',''),',','.') ,'Е','E'),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O'),'.','') = '"+ check_gosttu+   
                                        "' AND replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(naim)" +
                                        ",' ',''),',','.') ,'Е','E'),'-',''),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O') = '" + check_naim + "'";*/
                                    quer = "SELECT e.PIN From dbo.Tb_Element e, dbo.tb_elementname n Where e.id = n.id AND "+
                                        "replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(GOSTTU)" +
                                        ",' ',''),',','.') ,'Е','E'),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O'),'.',''),'И','U'),'З','3'),'+',''),'-','') = '" + check_gosttu +
                                        "' AND replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(LTRIM(RTRIM(n.element))+RTRIM(LTRIM(e.naim)))" +
                                        ",' ',''),',','.') ,'Е','E'),'-',''),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O'),'%',''),'З','3'),'И','U') = '" + check_naim + "'";

    Читаю старый код и радуюсь, что больше с ним не работаю. Правим результаты кривых рук операторов, заводящих данные.

    Grover, 04 Декабря 2012

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

    +121

    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
    This awesome yet simple and pragmatic PHP library performs an addition of two numbers.
    
    In early stages of Internet, developers were forced to work with poor, dry, functional, horrific languages. Everything had to be done through austere functions and operators. There was no objects. No interfaces. No dependency injection.
    
    For example, to make something as simple as an addition, our dads had to write: 1+1. Yeah, really.
    
    Hopefuly now, we have PHP 5.3 and its solid OOP implementation. SimplePHPEasyPlus lets you make this addition in a more fashionable way, using real OOP. It is fast, simple, flexible and tested. To add 1 to 1, all you have to do is:
    
    use SimplePHPEasyPlus\Number\NumberCollection;
    use SimplePHPEasyPlus\Number\SimpleNumber;
    use SimplePHPEasyPlus\Number\CollectionItemNumberProxy;
    use SimplePHPEasyPlus\Parser\SimpleNumberStringParser;
    use SimplePHPEasyPlus\Iterator\CallbackIterator;
    use SimplePHPEasyPlus\Operator\AdditionOperator;
    use SimplePHPEasyPlus\Operation\ArithmeticOperation;
    use SimplePHPEasyPlus\Operation\OperationStream;
    use SimplePHPEasyPlus\Engine;
    use SimplePHPEasyPlus\Calcul\Calcul;
    use SimplePHPEasyPlus\Calcul\CalculRunner;
    
    
    $numberCollection = new NumberCollection();
    
    $numberParser = new SimpleNumberStringParser();
    
    $firstParsedNumber = $numberParser->parse('1');
    $firstNumber = new SimpleNumber($firstParsedNumber);
    $firstNumberProxy = new CollectionItemNumberProxy($firstNumber);
    
    $numberCollection->add($firstNumberProxy);
    
    $secondParsedNumber = $numberParser->parse('1');
    $secondNumber = new SimpleNumber($secondParsedNumber);
    $secondNumberProxy = new CollectionItemNumberProxy($secondNumber);
    
    $numberCollection->add($secondNumberProxy);
    
    $addition = new AdditionOperator('SimplePHPEasyPlus\Number\SimpleNumber');
    
    $operation = new ArithmeticOperation($addition);
    
    $engine = new Engine($operation);
    
    $calcul = new Calcul($engine, $numberCollection);
    
    $runner = new CalculRunner();
    
    $runner->run($calcul);
    
    $result = $calcul->getResult();
    $numericResult = $result->getValue(); // 2
    This library is now available for production purposes. Enjoy!

    [КО]Складывает 2 числа[/КО]

    Vasiliy, 01 Декабря 2012

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