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

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

    +165

    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
    function ChangePhoto(num, photo)
    {
        if (photo.className != 'photo_selected')
        {
        var image1 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image1");
        var image2 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image2");
        var image3 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image3");
        var image4 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image4");
        var image5 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image5");
        var image6 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image6");
        
        if (image1 != null) image1.className = 'photo_notselected';
        if (image2 != null) image2.className = 'photo_notselected';
        if (image3 != null) image3.className = 'photo_notselected';
        if (image4 != null) image4.className = 'photo_notselected';
        if (image5 != null) image5.className = 'photo_notselected';
        if (image6 != null) image6.className = 'photo_notselected';
        
        
        photo.className = 'photo_selected';
        Hide(0);
        setTimeout("ChangeSrc("+num+")", 300);
        setTimeout("ShowPhoto()", 400);
        }
    }

    Чо мне ща сказал? Цыклы мне ща сказал? Какие тенна цыклы, ыдисюданна!

    Строчки 22, 23 активируют какое-то хитрожопое многопоточное отображение фоток со взаимными блокировками и ожиданием друг друга по таймеру с интервалами в 10 мс.

    telnet, 11 Марта 2011

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

    +138

    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
    76. 76
    77. 77
    78. 78
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <ctime>
    #include <signal.h>
    #include <sys/time.h>
    #include <fcntl.h>
    #include <termios.h>
    #include <time.h>
    
    #include <iostream>
    
    using namespace std;
    
    struct termios savetty;
    struct termios tty;
    char num[]="0123456789QWERTYUIOPASDFGHJKLZXCVBNM";
            char let[]="!\",#$%&'()*qwertyuiopasdfghjklzxcvbnm";
    int t=1;
    int tm=0;
    int opnum=0;
      char buffer[30];
    char var[1000];
    char out[1000];
    struct timeval tv;
    struct timeval tv2;
    int main()
    {
      if ( !isatty(0) ) {
      fprintf (stderr, "stdin not terminal\n");
      exit (1);
      };
    
    tcgetattr (0, &tty);
    savetty = tty;
    tty.c_lflag &= ~(ICANON|ISIG);
    tty.c_cc[VMIN] = 1;
    tcsetattr (0, TCSAFLUSH, &tty);
    
      srand(time(0));
    
      int i=0;
      bool c=true;
      time_t curtime;
      int passLen=200+rand()%400;
      for(int i=0;i<=passLen;i++){
        int s=rand()%2;
        if(s==1){
          out[i]=let[rand()%37];
        } else {
          out[i]=num[rand()%35];
        };
        if((i%5)==0 && i!=0)out[i]=' ';
      };
      out[passLen]='\0';
      int tt=gettimeofday(&tv, NULL);
      if(tt<0)exit(0);
      printf("%s\n",out);
      while(out[i]!='\0')
      {
        var[i]=getchar();
        if(var[i]!=out[i]){
          opnum++;
          printf("Er%c",out[i]);
        };
        i++;
      };
      tt=gettimeofday(&tv2, NULL);
      if(tt<0)exit(0);
      int tm=tv2.tv_sec-tv.tv_sec;
      int v=(passLen*60)/tm;
      int min=tm/60;
      tm%=60;
      printf("Time %d min %d sec\n",min,tm);
      cout<<"Num of errors "<<opnum<<" Speed "<<v<<endl;
      tcsetattr (0, TCSAFLUSH, &savetty);
      
    };

    Клавиатурный тренажер

    AliceGoth, 09 Марта 2011

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

    +171

    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
    void Cryptogram(const vector<string> &vector1, vector<string> &vector2)
    {
      string word;
      char new_letter;
      long i, j, wordSize, vecSize, vecSize2;
      vecSize = vector1.size();
      for(j=0; j<vecSize; j++)
        {
          word = vector1[j];
          //cout<<word<<endl;
          wordSize = word.size();
          cout<<wordSize<<endl;
          for(i=0; i<wordSize; i++)
      {
        new_letter = word[i];
        cout<<"& " << new_letter<< " " << isalpha(new_letter) << endl;
        if(isalpha(new_letter)==true)
          {
            if(isupper(new_letter)==true)
        {
    
          if (new_letter == 'A')
            new_letter = 'W';
          else if(new_letter == 'B')
            new_letter = 'Y';
          else if(new_letter == 'C')
            new_letter = 'I';
          else if(new_letter == 'D')
            new_letter = 'J';
          else if(new_letter == 'E')
            new_letter = 'K';
          else if(new_letter == 'F')
            new_letter = 'C';
          else if(new_letter == 'G')
            new_letter = 'U';
          else if(new_letter == 'H')
            new_letter = 'V';
          else if(new_letter == 'I')
            new_letter = 'D';
          else if(new_letter == 'J')
            new_letter = 'P';
          else if(new_letter == 'K')
            new_letter = 'Q';
          else if(new_letter == 'L')
            new_letter = 'L';
          else if(new_letter == 'M')
            new_letter = 'Z';
          else if(new_letter == 'N')
            new_letter = 'H';
          else if(new_letter == 'O')
    
            new_letter = 'T';
          else if(new_letter == 'P')
            new_letter = 'G';
          else if(new_letter == 'Q')
            new_letter = 'A';
          else if(new_letter == 'R')
            new_letter = 'B';
          else if(new_letter == 'S')
            new_letter = 'M';
          else if(new_letter == 'T')
            new_letter = 'X';
          else if(new_letter == 'U')
            new_letter = 'E';
          else if(new_letter == 'V')
            new_letter = 'F';
          else if(new_letter == 'W')
            new_letter = 'O';
          else if(new_letter == 'X')
            new_letter = 'N';
          else if(new_letter == 'Y')
            new_letter = 'R';
          else if(new_letter == 'Z')
            new_letter = 'S';
        }

    Cryptogram function, it's much longer, with 26 if statements if the letter is lowercase.

    BigEndian, 06 Марта 2011

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

    +82

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    for (FileItem item : items) {
        try {
            item.write(new File(repo 
                    + System.currentTimeMillis() 
                    + "_" + item.getName()));
        } catch (Exception ex) {
            log.error(ex, ex);
        }
        mav.addObject("result", "http://xxx.xx/uploads/"
                + System.currentTimeMillis() 
                + "_" + item.getName());
    }

    долго думал почему имя файла на диске не совпадает с именем в ссылке.

    zlob.jc, 05 Марта 2011

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

    +158

    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
    <script language="php">
    $curl=curl_init("http://www.sportbox.ru");
    $proxy='us:psw@IP:port';
     
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_PROXY, $proxy);
     
    $content=curl_exec($curl);
     
    preg_match_all('#<h3><a href(.*)>(.*)</a></h3>#siU', $content, $titles);
    foreach ($titles[2] as $title)
    echo "<b>$title</b><br>";
     
    curl_close($content);
    </script>

    qbasic, 03 Марта 2011

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

    +169

    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
    <?php
    	exit
    	(
    		empty($_POST['key']) ||
    		empty($_POST['time']) ||
    		empty($_POST['email']) ||
    		(int)$_POST['time'] != $_POST['time'] ||
    		strlen((int)$_POST['time']) != strlen($_POST['time']) ||
    		!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $_POST['email']) ||
    		($_SERVER['REQUEST_TIME'] - $_POST['time']) > 60 * 60 ||
    		md5(str_rot13(md5($_POST['time']))) != $_POST['key']
    		?'-':'+'
    	);
    ?>

    Вот Ajax ответ

    wyand, 02 Марта 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    /*	Адаптация под оперу	*/
    if ( stristr($_SERVER['HTTP_USER_AGENT'], 'Opera') )
    	echo "<input type=hidden value='file_ok' name='action'><br><input type=\"image\" src=\"".$url."images/buttons/button_file_ok.png\">";
    else 
    	echo "<br><input type=\"image\" src=\"".$url."images/buttons/button_file_ok.png\" value=\"file_ok\" name=\"action\">";

    особый говнокод для Оперы
    http://my.opera.com/russian/forums/topic.dml?id=918821

    xxx, 28 Февраля 2011

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

    +92

    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
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    type BOOK= record
          Name:string[20];
          Avtor:string[20];
          Price:integer;
          end;
    
     BOOKS=Array[1..100] of BOOK;
     F= File of BOOK;
    procedure Vvod(var biblioteka: books; var File_tBIBL:F; var n:integer);
    Procedure AVTOR_KN(VAR File_tBIBl:F; VAR File_tBIBl_AVTOR:text);
    Procedure TIP_TEXT(VAR File_tBIBl:F; VAR File_tBIBl_text:text);
    Function MIN_CENA( var File_tBIBl:F ; n:integer ):integer;
    procedure Vvod(var biblioteka: books; var File_tBIBL:F; var n:integer);
      var i:integer;
      begin
       rewrite(File_tBIBL);
    
      FOR i:=1 to n do begin
                     Writeln('  Vvedite nazvanie knigi');
                       readln(biblioteka[i].Name);
                     Writeln('  Vvedite avtora');
                       readln(biblioteka[i].Avtor);
                     Writeln('  Vvedite cenu');
                       readln(biblioteka[i].Price);
                     Write(File_tBIBL,biblioteka[i]);
                     writeln;
                       end;
      close(File_tBIBL);
      end;
    
      Procedure TIP_TEXT(VAR File_tBIBl:F; VAR File_tBIBl_text:text);
       var BIBLIOTEKA:BOOk;
    
         BEGIN
    
       reset(File_tBIBl);
       rewrite(File_tBIBl_text);
    
       WHILE not eof(File_tBIBl) do begin
                                    read(File_tBIBl,BIBLIOTEKA);
                                    writeln(File_tBIBl_text,BIBLIOTEKA.Name);
                                    writeln(File_tBIBl_text,BIBLIOTEKA.Avtor);
                                    writeln(File_tBIBl_text,BIBLIOTEKA.Price);
                                    writeln(File_tBIBl_text);
                                    writeln(File_tBIBl_text);
                                    end;
       close(File_tBIBl);
       close(File_tBIBl_text);
       end;
    
      Procedure AVTOR_KN(VAR File_tBIBl:F; VAR File_tBIBl_AVTOR:text);
       var BIBLIOTEKA:BOOk; Av:string;
    
         BEGIN
    
    
       reset(File_tBIBl);
       rewrite(File_tBIBl_AVTOR);
    
       Writeln('Vvedite iskomogo avtora');
       readln(Av);
    
     WHILE not eof(File_tBIBl) do   begin
                                    read(File_tBIBl,BIBLIOTEKA);
                                    if BIBLIOTEKA.Avtor = Av then begin
                                                                 writeln(File_tBIBl_AVTOR,BIBLIOTEKA.Name);
                                                                 writeln(File_tBIBl_AVTOR,BIBLIOTEKA.Avtor);
                                                                 writeln(File_tBIBl_AVTOR,BIBLIOTEKA.Price:4);
                                                                 writeln(File_tBIBl_AVTOR);
                                                                 end;
                                    end;
       close(File_tBIBl);
       close(File_tBIBl_AVTOR);
        end;
    
    var nomer,i,min:integer;BIBLIOTEKA:BOOks; SIZE:integer;
    begin
      reset(File_tBIBl);
     size:=1;
        while  not eof(File_tBIBl) do
            with BIBLIOTEKA[size] do
        begin
            readln(File_tBIBl , BIBLIOTEKA.name);
             Readln(File_tBIBl,BIBLIOTEKA.Avtor);
            readln(File_tBIBl,BIBLIOTEKA.Price);
    
            inc(size);
        end;
        dec(size);
     min:=BIBLIOTEKA[1].Price;
    for i:=1 to size  do
    if BIBLIOTEKA[i].Price< min then        begin
                                            min:=BIBLIOTEKA[i].Price;
                                            nomer:=i;
                                            end;

    Juris_Kabanis, 27 Февраля 2011

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

    −102

    1. 1
    instanceId = Math.random().toString().split(".")[1];

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

    wvxvw, 20 Февраля 2011

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class ForDemo {
      public static void main(String args[]) {
        long C;
    	
    	for(C = 0; C < 9999999; C++)
    	System.out.println("This is count: " + C);
    	System.out.println("Done!");
    	}
    }

    Говнокод убивающий командную строку =),
    Применять только по необходимости(!)
    Так же можно проследить между строк упоминание о C++

    Akira, 17 Февраля 2011

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