1. Python / Говнокод #6520

    −97

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    #include <stdio.h>
    #include <signal.h>
    #include <unistd.h>
    #include <sys/wait.h>
    void sighndlr_1(int signo) { //obrabot4ik dlya 1go processa
        printf("I'm child process #1. I've got SIGINT! :) So, I won't do anything...\n"); //prosto vyvod na ekran soobscheniya o polu4enii signala
    }
    
    void sighndlr_2(int signo) { //dlhya 2go
        printf("I'm child process #2. I've got SIGINT :)\n");
    }
    
    int main(int argc, char **argv) {
        pid_t pid1,pid2,pid3,pid4; //4 do4ernih processa
        static struct sigaction act1,act2,act3; //3 struktury dlya 3h processov
        act1.sa_handler = sighndlr_1; //ustanovka obrabot4ika dlya 1 struktory
        act2.sa_handler = sighndlr_2; //dlya 2i
        act3.sa_handler = SIG_IGN; //ignoriruem signal v 3 strukture
        switch(pid1 = fork()) { //sozdaem 1 do4erniy process
        case -1: //vihodim pri oshibke sozdaniya
    	printf("Error fork\n");
    	exit(1);
    	break;
        case 0:
    	printf("Child process #1 started (pid = %d)\n", getpid()); //soobshenie ob uspeshnom sozdanii i vyvod pid
    	sigaction(SIGINT,&act1,NULL); //ustanovka struktury obrabot4ika dlya SIGINT
    	for(;;) pause(); //beskone4nyi cikl
    	break;
        default:
        switch(pid2 = fork()) { //sozdaem 2 process
        case -1:
    	printf("Error fork\n");
    	exit(1);
    	break;
        case 0:
    	printf("Child process #2 started (pid = %d)\n", getpid());
    	sigaction(SIGINT,&act2,NULL); //dlya SIGINT
    	sigaction(SIGQUIT,&act3,NULL); //ignorim SIGQUIT
    	for(;;) pause();
    	break;
        default:
        switch(pid3 = fork()) { //3 process
        case -1:
    	printf("Error fork\n");
    	exit(1);
    	break;
        case 0:
    	printf("Child process #3 started (pid = %d)\n", getpid());
    	sigaction(SIGINT,&act3,NULL); //ignorim SIGINT
    	for(;;) pause();
    	break;
        default:
        switch(pid4 = fork()) { //4 process
        case -1:
    	printf("Error fork\n");
    	exit(1);
    	break;
        case 0:
    	printf("Child process #4 started (pid = %d)\n", getpid());
    	setsid(); //menyaem identifikator seansa dlya processa
    	printf("Process #4 changed sid\n");
    	for(;;) pause();
    	break;
        default:
        printf("Finishing parent process... (pid = %d)\n", getpid());
        exit(0); //zavershaetsya roditelsky process
        break;
        }        
        break;
        }
        break;
        }
        break;
        }
    }

    Лаба по курсу операционных систем. Нужно было создать 4 дочерних процесса, и для каждого процесса создать свои обработчики для сигнала SIGINT или SIGQUIT. Полученный говнокод полон повторяющихся конструкций, и слишком сильно запутан операторами switch-case.

    Boten, 30 Апреля 2011

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

    −102

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    210 IF A$='1' THEN 2000
    220 IF A$='2' THEN 2010
    230 IF A$='3' THEN 2020
    240 IF A$='4' THEN 2030
    250 IF A$='5' THEN 2040
    260 IF A$='6' THEN 2060
    270 IF A$='7' THEN 2070
    280 IF A$='8' THEN 2080
    285 IF A$='9' THEN 4000
    290 IF A$='10' THEN 3000

    говнокод прямо с обложки книги по прикладному васику для ИТР

    bugmenot, 30 Апреля 2011

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

    +121

    1. 1
    2. 2
    3. 3
    for i:=1 to 200000000 do;//имитация паузы
    
    ggProcess.Progress:=ggProcess.Progress+13;

    Ксакеп снова в теме:
    http://www.xakep.ru/magazine/xa/016/050/2.asp
    Имитация паузы, блеять.

    Govnocoder#0xFF, 30 Апреля 2011

    Комментарии (26)
  4. PHP / Говнокод #6517

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if($password===$_POST['password'] && $login===$_POST['login'])
    	{	
    // устанавливаем login & pass	
    	$_SESSION['login']=$_POST['login'];	
    	
    	$_SESSION['password']=$_POST['password'];
    // Перенаправляем в админ панель	
    	Header("Location: config.php");	
    	}
    else { ... }

    NemoReturns, 29 Апреля 2011

    Комментарии (72)
  5. JavaScript / Говнокод #6516

    +164

    1. 1
    <a onclick="javascript:location.href='news_id_42297.html'" href="#block03-1">

    http://www.topnews.ru/ (внизу новости с 11-й по 20-ю)
    А теперь <del>кликните колесиком</del> наведите на это безобразие курсор. Молодцы, теперь отведите.

    ReallyBugMeNot, 29 Апреля 2011

    Комментарии (15)
  6. C# / Говнокод #6515

    +113

    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
    public bool Read_XMl_File (XDocument Xml_Document, ref game_data Game_Data) { 
                bool Is_Success=false;          /* Captures this function's result */
    
                try { 
                    this.Xml_Data = (game_data)Game_Data;
    /*              Recursively read through entire XML Document */ 
                    Xml_Document.Root.RecursivelyProcess ( 
                        Process_Child_Element,
                        Process_Parent_Element_Open,
                        Process_Parent_Element_Close);
                    Is_Success = true;
                    }
    
                catch (Exception ex) { throw ex; }
    
                Game_Data = this.Xml_Data;    /* Pass the data back to Xml_Data */
                return Is_Success;
                }
     public static void RecursivelyProcess (
                    this XElement element,
                    Action<XElement, int> childAction,
                    Action<XElement, int> parentOpenAction,
                    Action<XElement, int> parentCloseAction) {  
                if (element == null) { throw new ArgumentNullException ("element"); } 
                element.RecursivelyProcess (0, childAction, parentOpenAction, parentCloseAction);  
                }  
    
     private static void RecursivelyProcess (  
                this XElement element,  
                int depth,  
                Action<XElement, int> childAction,  
                Action<XElement, int> parentOpenAction,  
                Action<XElement, int> parentCloseAction)  { 
     
                if (element == null)  { throw new ArgumentNullException ("element"); } 
                if (!element.HasElements) {         /* Reached the deepest child */
                    if (childAction != null) { childAction (element, depth); }  
                    }  
                else  {                             /* element has children */
                    if (parentOpenAction != null)  { parentOpenAction (element, depth); }  
                    depth++;  
                   
                    foreach (XElement child in element.Elements ())  {  
                        child.RecursivelyProcess ( depth,  childAction,  parentOpenAction,  parentCloseAction );  
                        }     
                    depth--;  
                    
                    if (parentCloseAction != null)  {  parentCloseAction (element, depth);  }
                    }  
                }
            }

    Avance, 29 Апреля 2011

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

    +158

    1. 1
    if(typeof n!="number"&&(k==Number||!(n instanceof Number))||p.round(n)!=n||n==NaN||n==Infinity)return!1;

    http://www.google-analytics.com/ga.js
    Инженеры в Гугле знают толк в JavaScript'e.

    wvxvw, 29 Апреля 2011

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

    +192

    1. 1
    class AutocompleteAddressZaplatka2 extends AutocompleteAddressZaplatka

    Фундаментальные объектно-ориентированные костыли ...

    _tL, 29 Апреля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $cur = date('Y-m-d',time());
    $date_arr = explode('-',$cur);
    $year =$date_arr[0];
    $month =$date_arr[1];
    $day =$date_arr[2];

    _tL, 29 Апреля 2011

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

    +166

    1. 1
    enum mysymbols={true,flase}

    С товарищем в аудитории на доске писали разные говнокоды, кто какие вспомнит. Заходит препод, оглянул взглядом доску, улыбнулся, и начал писать свою версию (см. выше), приговаривая: "Вот веселуха то начнется!" =)

    1_and_0, 29 Апреля 2011

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