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

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

    −96

    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
    import random
    
    while 0<1:
        inn_d=str(random.randint(100000000,999999999))
        a=int(inn_d[:1])*2
        b=int(inn_d[1:2])*4
        c=int(inn_d[2:3])*10
        d=int(inn_d[3:4])*3
        e=int(inn_d[4:5])*5
        f=int(inn_d[5:6])*9
        g=int(inn_d[6:7])*4
        l=int(inn_d[7:8])*6
        m=int(inn_d[8:9])*8
        x=a+b+c+d+e+f+g+l+m
        y=x%11
        if y%11==10:
            y=0
        print str(inn_d)+str(y)

    Такой вот генератор ИННов

    pl7ofit, 28 Июня 2014

    Комментарии (11)
  3. C# / Говнокод #16228

    +132

    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
    private object N(Func<object> func)
            {
                try
                {
                    return func();
                }
                catch (NullReferenceException)
                {
                    return null;
                }
            }
    
    ...
    
    int? val = (int?)N(() => oldAttr.parent_value.Analyses_attribute);
    
    ...

    Мощный метод для поддержки паровозов.

    MainGovnokoder, 25 Июня 2014

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

    +133

    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
    string parser(string chto, string chem)
                {
                    int dlina = chem.Length;
                    int kol = chto.Length;
                    string ret = null;
                    int shet = 0;
                    int r = 0;
                    int nom = 0;
                    for (int i = 0; i < kol; i++)
                    {
                        if (chto[i] == chem[0] && shet == 0)
                        {
                            for (int j = i; j < dlina + i; j++)
                            {
                                if (chto[j] == chem[r])
                                {
                                    r++;
                                    shet++;
                                    nom = j;
                                }
    
                            }
                            if (shet != dlina)
                            {
                                shet = 0;
                                r = 0;
                                nom = 0;
                            }
                        }
                    }
                    int schet = nom + 3;
                    while (chto[schet] != '<')
                    {
                        ret += chto[schet];
                        schet++;
                    }
                    return ret;
                }

    Функция для парсинга подстроки

    vladb9582, 18 Июня 2014

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

    +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
    // ------------------------------
    // config on all machines
    akka {
      actor {
       provider = akka.remote.RemoteActorRefProvider
       deployment {
         /greeter {
           remote = akka.tcp://MySystem@machine1:2552
         }
       }
     }
    }
     
    // ------------------------------
    // define the greeting actor and the greeting message
    case class Greeting(who: String) extends Serializable
     
    class GreetingActor extends Actor with ActorLogging {
      def receive = {
        case Greeting(who) ⇒ log.info("Hello " + who)
     }
    }
     
    // ------------------------------
    // on machine 1: empty system, target for deployment from machine 2
    val system = ActorSystem("MySystem")
     
    // ------------------------------
    // on machine 2: Remote Deployment - deploying on machine1
    val system = ActorSystem("MySystem")
    val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
     
    // ------------------------------
    // on machine 3: Remote Lookup (logical home of “greeter” is machine2, remote deployment is transparent)
    val system = ActorSystem("MySystem")
    val greeter = system.actorSelection("akka.tcp://MySystem@machine2:2552/user/greeter")
    greeter ! Greeting("Sonny Rollins")

    Где найти такую же няшку под кресты?

    laMer007, 13 Июня 2014

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

    +98

    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
    procedure TForm1.FormCreate(Sender: TObject);
    var
      H: THandle;
      R: TRect;
      appbardata: tappbardata;
    
    begin
    
      sx := 0;
      sy := 0;
      ax := 0;
      ay := 0;
      sh := GetSystemMetrics(SM_CYSCREEN);
    
      ZeroMemory(@appbardata, SizeOf(tappbardata));
      SHAppbarmessage(5, appbardata);
    
      If appbardata.rc.TopLeft.X > 1 then
      begin
        ax := appbardata.rc.BottomRight.X - appbardata.rc.TopLeft.X;
        ax:=ax+4;
      end
      else
      ax:=6;
    
      If appbardata.rc.TopLeft.y > 1 then
      begin
        ay := appbardata.rc.BottomRight.y - appbardata.rc.TopLeft.y;
      ay:=ay+4;
      end
      else
      ay:=6;
    
      sx := (GetSystemMetrics(SM_CXSCREEN)-form1.ClientWidth-ax);
      sy := (GetSystemMetrics(SM_CYSCREEN)-form1.ClientHeight-ay);
    
      Form1.left := sx;
      Form1.Top :=sy;
    
    end;

    Выравнивание всплывающего окошка точно по правому краю.
    Даже не знаю, гк ли это, ибо глаз не видит себя. Но смотрится очень странно, почти как хак.

    brutushafens, 10 Июня 2014

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

    +162

    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
    switch ($Age){
    	case "30-35 лет" : $Age="30-35 лет";	break;
    	case "35-40 лет" : $Age="35-40 лет";	break;
    	case "40-45 лет" : $Age="40-45 лет";	break;
    	case "45-50 лет" : $Age="45-50 лет";	break;
    	case "50-55 лет" : $Age="50-55 лет";	break;
    	}
    switch ($Driving){
    	case "10-15 лет" : $Driving="10-15 лет";	break;
    	case "20-25 лет" : $Driving="20-25 лет";	break;
    	case "25-30 лет" : $Driving="25-30 лет";	break;
    	case "30-35 лет" : $Driving="30-35 лет";	break;
    	}
    	
    switch ($Register){
    	case "не в Москве" : $Register="не в Москве";	break;
    	case "Авиамоторная" : $Register="Авиамоторная";	break;
    	case "Автозаводская" : $Register="Автозаводская";	break;
    	case "Академическая" : $Register="Академическая";	break;
    	case "Александровский сад" : $Register="Александровский сад";	break;
    	case "Алексеевская" : $Register="Алексеевская";	break;
    	case "Алтуфьево" : $Register="Алтуфьево";	break;

    И так далее все станции...
    Кто-нить понимает зачем? Программисту платили за количество строк?

    aaparin, 27 Мая 2014

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

    +17

    1. 1
    MagicClass::getInstance().getFooFactory().createFoo().killMePlease();

    http://habrahabr.ru/post/222007/
    А вообще "Внедрение зависимостей в C++ через контейнеры" - та ещё традиционная специальная олимпиада крестовиков.

    LispGovno, 20 Мая 2014

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

    +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
    var fixGetMoreOrders = function(data){
        var i = 0;
        $.each(data.resultObject, function(k,v){
            i++;
        });
        if(i>=10){
            $('.btnGetOrders').css('display', 'block');
        }
        if(i<10){
            $('.btnGetOrders').css('display', 'none');
        }
    };

    Предыдущему разработчику нужно было посчитать количество ордеров, при том, что поле data['count'] вертается с сервера =)

    makzimko, 16 Мая 2014

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    try
    {
        int.TryParse(splitString[j], out I[i, j]);
    }
    catch (Exception)
    {
        Console.WriteLine("...");
        break;
    }

    sys2712, 13 Мая 2014

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

    +154

    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
    <?php function view_admin_article_categories_show_category(Model_Article_Category $category, $marker) { ?>
        <tr>
            <td><?=$category->id?></td>
            <td><a href="<?=Route::url('admin_articles_category_edit', array('id' => $category->id))?>"><?=$marker?><?=$category->title?></a></td>
            <td><?=$category->alias?></td>
            <td><?=$category->seo_title?></td>
            <td>
                <a href="<?=Route::url('admin_articles_category_edit', array('id' => $category->id))?>"><span class="icon-edit"></span></a>
                &nbsp;
                <a href="<?=Route::url('admin_article_remove', array('id' => $category->id))?>"><span class="icon-remove"></span></a>
            </td>
        </tr>
    <?php } ?>
    <?php
        function view_admin_article_categories_show_child_categories(array $categories, array $current = null, $marker = '')
        {
            if($current === null)
            {
                $parents = queryToArray::from($categories)
                        ->where(function($value){
                            return !is_numeric($value->parent_id);
                        })
                        ->result();
                view_admin_article_categories_show_child_categories($categories, $parents, '');        
            } else {
                foreach($current as $parent)
                {
                    view_admin_article_categories_show_category($parent, $marker);
                    $childs = queryToArray::from($categories)
                        ->where(function($value)use($parent){
                            return $value->parent_id === $parent->id;
                        })
                        ->result();
                    if($childs) {
                        view_admin_article_categories_show_child_categories($categories, $childs, $marker.'&minus; ');
                    }
                }
            }
        }?>

    Проект на Kohana. Где-то во вьюхе.

    Strannik1941, 11 Мая 2014

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