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

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

    +80

    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
    thread = new Thread() {
      @Override 
      public void run() {
        try {
          while( !dataProcessor.isFinished() ) {
            dataProcessor.execute();
            
            Thread.sleep( 60 * 1000L );
          }        
        } catch ( Throwable t ) {
          logger.fatal( "Fatal error in daemon thread", t );
        }
      }
    };
    
    thread.run();

    Вот такое оно параллельное выполнение. Задачка для догадливых.

    galak, 13 Июня 2011

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

    +166

    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
    #ifdef _UNICODE
    
    typedef wchar_t char_t;
    
    namespace std
      {
      typedef wstring string_t;
      typedef wistream istream_t;
      typedef wostream ostream_t;
      typedef wifstream ifstream_t;
      typedef wofstream ofstream_t;
      typedef wostringstream ostringstream_t;
      typedef wistringstream istringstream_t;
      typedef wstringstream stringstream_t;
      }
    
    #else // MBCS or SBCS
    
    typedef char char_t;
    
    namespace std
      {
      typedef istream istream_t;
      typedef ostream ostream_t;
      typedef ifstream ifstream_t;
      typedef ofstream ofstream_t;
      typedef string string_t;
      typedef ostringstream ostringstream_t;
      typedef istringstream istringstream_t;
      typedef stringstream stringstream_t;
      }
    
    #endif // _UNICODE

    Продолжаю разребать мега-ровный-код убер-чётких-кодеров.
    В этой серии:
    1. Иньекции в чужой namespace (погладь std сцуко)
    2. Windows[ANSI/UNICODE] == C++[std::string/std:wstring], кодировко-зависимый-независимый код
    3. Читайте матчасть std::basic_string<char> == std::string

    VladislavKurmaz, 10 Июня 2011

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

    +166

    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
    //Класс для генерации кнопок перелистывания страниц
    
    class Pages {
    
        //Если пользователь на англ версии сайта и он на первой странице, генерируем кнопку "Next page"
        public function GeneratePage1En() {
            $this->NextPageHTML = "<a id=\"pg-next\" class=\"pg-next\" href=\"{$this->Se}.php?Page=2&Q={$this->Question}&D={$this->Domain}&Td={$this->Typedate}\">Next page</a>";
        }
    
        //Если пользователь на рус версии сайта и он на первой странице, генерируем кнопку "Следующая страница"
        public function GeneratePage1Ru() {
            $this->NextPageHTML = "<a id=\"pg-next\" href=\"{$this->Se}.php?Page=2&Q={$this->Question}&D={$this->Domain}&Td={$this->Typedate}\">Следущая страница</a>";
        }
    
        //Если пользователь на англ версии сайта и он на >2 странице генерируем кнопку "Next Page" и "Previous Page"
        public function GeneratePagesEn($Page) {
            $this->PrevPageHTML = "<a id=\"pg-prev\" class=\"pg-prev\" href=\"{$this->Se}.php?Page={$this->PrevPage}&Q={$this->Question}&D={$this->Domain}&Td={$this->Typedate}\">Previous page</a>";
            $this->NextPageHTML = "<a id=\"pg-next\"  class=\"pg-next\"  href=\"{$this->Se}.php?Page={$this->NextPage}&Q={$this->Question}&D={$this->Domain}&Td={$this->Typedate}\">Next page</a>";
        }
    
        //Если пользователь на рус версии сайта и он на >2 странице генерируем кнопку "Следующая страница" и "Предыдущая страница"
        public function GeneratePagesRu($Page) {
            $this->PrevPageHTML = "<a id=\"pg-prev\" class=\"pg-prev\" href=\"{$this->Se}.php?Page={$this->PrevPage}&Q={$this->Question}&D={$this->Domain}&Td={$this->Typedate}\">Предыдущая страница</a>";
            $this->NextPageHTML = "<a id=\"pg-next\"  class=\"pg-next\"  href=\"{$this->Se}.php?Page={$this->NextPage}&Q={$this->Question}&D={$this->Domain}&Td={$this->Typedate}\">Следующая страница</a>";
        }
    }

    Недавно увидел такую вот реализацию "листания" страниц в блоге.
    Применение довольно простое. Сначала идет несколько проверок (на какой пользователь странице и какая у него версия сайта - рус или англ), и уже исходя от этого, генерируются нужные кнопки (вызывается нужная функция).
    Из особенностей - максимально кривое использование возможностей ООП))

    MyNameIsWinner, 09 Июня 2011

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

    −167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    def word(long):
       s=''
       for j in range(0,long):
          lit =  struct.unpack('c',plik.read(1))[0]
          if ord(lit)!=0:
             s+=lit
             if len(s)>300:
                break
       return s

    WGH, 06 Июня 2011

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $opdirbase=opendir(H.'sys/fnc');
    while ($filebase=readdir($opdirbase))
    {
    if (eregi('\.php$',$filebase))
    {
    include_once(H.'sys/fnc/'.$filebase);
    }
    }

    Вот так вот инклюдится код в одной в вап cms.В дериктории файлы по 200-300кб.

    jQuery, 03 Июня 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $sql1 = '(';
    ........
    if(!is_array($sql1))
    {
    	$sql1 = array();
    }

    А вдруг? Переменные иногда сами превращаются в массивы ...

    _tL, 30 Мая 2011

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

    +164

    1. 1
    IEB = (uagent.indexOf('msie') != -1) ? true : false;

    Мартин, 28 Мая 2011

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

    +114

    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
    procedure TForm1.Button1Click(Sender: TObject);
      var
        a,b,c,x:integer;
        chas, nedel1,nedel2,nedel3:integer;
    begin
      a:=0;
      b:=0;
      c:=0;
      repeat
        chas:= strtoint (edit1.text);
        nedel1:= strtoint (edit2.text);
        nedel2:= strtoint (edit3.text);
        nedel3:= strtoint (edit4.text);
        x:=((nedel1*a)+(nedel2*b)+(nedel3*c));
        if chas<>((nedel1*a)+(nedel2*b)+(nedel3*c)) then
          a:=a+1;
        if chas<>((nedel1*a)+(nedel2*b)+(nedel3*c)) then
          b:=b+1;
        if chas<>((nedel1*a)+(nedel2*b)+(nedel3*c)) then
          c:=c+1;
      until chas=x;
      label1.Caption:=inttostr (a);
      label2.Caption:=inttostr (b);
      label3.Caption:=inttostr (c);
    end;
    end.

    евклид плачет

    bugmenot, 27 Мая 2011

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    static $table_classes = array (
      0 => 'App',
      1 => 'Plugin',
      2 => 'AppUser',
      3 => 'Contact',
      4 => 'Email',
      5 => 'Link',
      6 => 'Mobile',
      7 => 'Session',
      8 => 'User',
    );

    VASMAN, 25 Мая 2011

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

    +73

    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
    /**
    * Простейший калькулятор
    * Ввод чисел производиться с клавиатуры , присутствуют проверки на
    * попытку деления на 0 и пустые значения чисел. Также присутствует
    * исключение на тот случай , когда пользователь ввёл вместо цифр буквы.
    * @author Anonym
    * @version 0.1
    */
    import java.io.*;
    
    public class Calculator {
    	public static void main(String args[]) throws java.io.IOException {
    	double z,x1,y1;
    	char read;
    	String x,y;
    	BufferedReader x3,y3;
    	// Вводим значения переменных
    	System.out.println("Write x and y by Enter");
    	x3 = new BufferedReader(new InputStreamReader(System.in));
    	y3 = new BufferedReader(new InputStreamReader(System.in));
    	x = x3.readLine();
    	if (x.equalsIgnoreCase("")) {
    	System.out.println("Empty value!");
    	}
    	y = y3.readLine();
    	if (y.equalsIgnoreCase("")) {
    	System.out.println("Empty value!");
    	}
    	if (x.equalsIgnoreCase("") && y.equalsIgnoreCase("")) {
    	System.out.println("Program Terminated!");
    	System.exit(0);
    	}
    	try{
    	x1 = Double.parseDouble(x);
    	y1 = Double.parseDouble(y);
    	// Выводим переменные на консоль
    	System.out.println("x="+x1+'\n'+"y="+y1);
    	// Выводим действия на консоль
    	System.out.println("Choose one:\n1.+\n2.-\n3.*\n4./");
    	read = (char) System.in.read();
    	switch(read){
    		case '1':
    		z =x1+y1;
    		System.out.println("x+y="+z);
    		break;
    		case '2':
    		z =x1-y1;
    		System.out.println("x-y="+z);
    		break;
    		case '3':
    		z =x1*y1;
    		System.out.println("x*y="+z);
    		break;
    		case '4':
    		if(y1 == 0) {
    		System.out.println("Can't divide by 0");
    		} else {
    		z =x1/y1;
    		System.out.println("x/y="+z);
    		}
    		break;
    		default :
    		System.out.println("You write wrong number of operation!");
    		}
    		} catch(NumberFormatException exc) {
    			System.out.println("Wrong Number!");
    		}
    	}
    }

    Akira, 25 Мая 2011

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