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

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    QTextEdit *qte = new QTextEdit();
                    qte->setHtml(doc->toHtml());
                    qte->selectAll();
                    qte->textCursor().mergeBlockFormat(format);
                    qte->setTextColor(this->getTextForecolor());
                    doc->setHtml(qte->toHtml());
                    delete qte;

    Задание цвета текста QTextDocument (doc) через анал.

    des-1008d, 25 Ноября 2010

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    // Setted bit
    	private static final int TRUE_BIT = 1;
    
    ...
    	public static final int LAST_PARAGRAPH = 0x01;
    	public static final int FIRST_PARAGRAPH = 0x02;
    ...
    	
    	if (TRUE_BIT == (paragraphFlag & ParagraphProperties.FIRST_PARAGRAPH) >>> 1) {

    mlg7, 24 Ноября 2010

    Комментарии (5)
  4. SQL / Говнокод #4721

    −849

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    -- Очищаем поле [PlanItemCodeNorm] от всех записей содержащих не цифры и точку
    UPDATE PIM SET [PlanItemCodeNorm] = ''
    -- SELECT PIM.*
    FROM [dbo].[PlanItem] PIM
    WHERE [PlanItemCodeNorm] <> ''
        AND REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
            REPLACE([PlanItemCodeNorm], '.', '' )
            , '0', '' ), '1', '' ), '2', '' ), '3', '' ), '4', '' ), '5', '' ), '6', '' ), '7', '' ), '8', '' ), '9', ''), '*', '' )
            <> ''

    ....

    HellMaster_HaiL, 23 Ноября 2010

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

    +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
    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
    function poс()
    {
    course = $('#points').text()
    if(course > 10) {
     $.post('/index/',{a:18, s:'LllMmm', subject:'Товар - стикер (чёрная кошка)', message:'Пользователь Гость заказал стикер (чёрная кошка).'});
     } 
     else {_uWnd.alert('Недостаточно баллов.','Ошибка')}
    }
    function pod()
    {
    course = $('#points').text()
    if(course > 15) {
     $.post('/index/',{a:18, s:'LllMmm', subject:'Товар - стикер (миллион долларов)', message:'Пользователь Гость заказал стикер (миллион долларов).'});
     } 
     else {_uWnd.alert('Недостаточно баллов.','Ошибка')}
    }
    function poe()
    {
    course = $('#points').text()
    if(course > 20) {
     $.post('/index/',{a:18, s:'LllMmm', subject:'Товар - стикер (на счастье)', message:'Пользователь Гость заказал стикер (на счастье).'});
     } 
     else {_uWnd.alert('Недостаточно баллов.','Ошибка')}
    }
    function pof()
    {
    course = $('#points').text()
    if(course > 25) {
     $.post('/index/',{a:18, s:'LllMmm', subject:'Товар - стикер (+100)', message:'Пользователь Гость заказал стикер (+100).'});
     } 
     else {_uWnd.alert('Недостаточно баллов.','Ошибка')}
    }
    function pog()
    {
    course = $('#points').text()
    if(course > 15) {
     $.post('/index/',{a:18, s:'LllMmm', subject:'Товар - стикер (настоящий мужчина)', message:'Пользователь Гость заказал стикер (настоящий мужчина).'});
     } 
     else {_uWnd.alert('Недостаточно баллов.','Ошибка')}
    }

    И так 16 функций...

    qePH, 22 Ноября 2010

    Комментарии (5)
  6. SQL / Говнокод #4658

    −120

    1. 1
    2. 2
    3. 3
    4. 4
    t = SQLEXEC(cc,"INSERT INTO CARDS (N, NAME1, NAME2, NAME3, PDEPARTMENT, PPOST, DCREATE, DMODIFY, PFIRM, PGROUP);
                       VALUES( '"+ALLTRIM('65905')+"', '"+UPPER('Ивасик')+"', '"+UPPER('Иван')+"', '"+UPPER('Андреевич')+"',;
                       '"+ALLTRIM('565')+"', '"+ALLTRIM('2184800')+"', '"+ALLTRIM('24/06/2009')+"', '"+ALLTRIM('07/07/2009')+"',;
                       '"+ALLTRIM('5')+"','"+ALLTRIM('5')+"')")

    Пример залива данных в базу на Visual FoxPro

    gavno2000, 17 Ноября 2010

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

    +143

    1. 1
    2. 2
    3. 3
    if (url == null) {
        throw new RuntimeException("Error reading resource " + url.getFile());
    }

    abatishchev, 16 Ноября 2010

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

    +177

    1. 1
    2. 2
    if(strlen($text)) return $text;
    return "";

    ferry-very-good, 16 Ноября 2010

    Комментарии (5)
  9. C# / Говнокод #4647

    +126

    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
    private void SetBorderColor()
    {
                if (AuthInfo.BorderColor)
                {
                    LinearGradientBrush lcBrush = new LinearGradientBrush();
                    lcBrush.StartPoint = new Point(0.5, 0);
                    lcBrush.EndPoint = new Point(0.5, 1);
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 249, 249, 249) });
                    lcBrush.GradientStops.Add(new GradientStop() {Color = Color.FromArgb(100,75,139,180), Offset = 0.331});
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 75, 139, 180), Offset = 0.853 });
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 249, 249, 249), Offset = 1 });
                    this.rectBackGround.Fill = lcBrush;
                }
                else
                {
                    LinearGradientBrush lcBrush = new LinearGradientBrush();
                    lcBrush.StartPoint = new Point(0.5, 0);
                    lcBrush.EndPoint = new Point(0.5, 1);
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 249, 249, 249) });
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 206, 109, 109), Offset = 0.331 });
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 206, 109, 109), Offset = 0.853 });
                    lcBrush.GradientStops.Add(new GradientStop() { Color = Color.FromArgb(100, 249, 249, 249), Offset = 1 });
                    this.rectBackGround.Fill = lcBrush;
                }
    }

    ОПТИМИЗИРОВАНО!!!
    я плакаль)

    HellMaster_HaiL, 16 Ноября 2010

    Комментарии (5)
  10. Pascal / Говнокод #4643

    +102

    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
    boo:=false;
    j:=length(edit1.text);
    for i:=1 to stringgrid1.RowCount do begin
     le:=length(stringgrid1.Cells[temp,i]);
     if (temp=1) or (temp=5) then begin
      if not (j>le) then
      for npo:=1 to ((le-j)+1) do begin
       str:=copy(Stringgrid1.cells[temp,i],npo,j);
       str_po:=str;
       if AnsiSameText(edit1.Text,str) then begin
        stringgrid1.Row:=i;
        boo:=true;
        break;
       end;
      end;
    end;

    Еще один шедевр. Выполняет поиск введенного текста в Edit в заданой колонке Strinngrid'а.

    Nikitiy_II, 16 Ноября 2010

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

    +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
    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
    class MysqlResultSet implements Iterator{
      private $strSQL;
      private $databasename;
      private $connection;
      private $result;
      private $valid;
      private $currentrow;
      private $key;
      const INDETERMINATE_TOTAL_NUMBER = 5001;
      const UNNECESSARY_SQL_CALC_FOUND_ROWS = 5002;
      const NOT_SELECT_QUERY = 5003;
      public function __construct( $strSQL, $databasename, $connection ){
        $this->strSQL = $strSQL;
        $this->connection = $connection;
        $this->databasename = $databasename;
        if(!mysql_selectdb($databasename, $connection)){
          throw new MySQLException(mysql_error(), mysql_errno());
        }
        if(!$this->result = mysql_query($strSQL, $connection)){
          throw new MySQLException(mysql_error(), mysql_errno());
        }
        if (stristr($strSQL,"SQL_CALC_FOUND_ROWS")){
          $msg = "No need to use SQL_CALC_FOUND_ROWS.";
          throw new MySQLException($msg, self::UNNECESSARY_SQL_CALC_FOUND_ROWS);
        }
        $this->rewind();
      }
      public function __destruct(){
        $this->close();
      }
      public function __call($name, $args){  
        $args = null;
        $name = "mysql_". $name;
        if(function_exists($name)){
          return call_user_func_array($name, $args);      
        }  
      }
      # Ну и так далее...

    31-38 строки: Не понятно, зачем нужно было вообще этот класс писать?!
    32-ая строка вообще сногсшибательна... (P.S. Из одной book по ООП в PHP5)

    dwinner, 15 Ноября 2010

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