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

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

    +143

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

    abatishchev, 16 Ноября 2010

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

    +177

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

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

    Комментарии (5)
  4. 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)
  5. 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)
  6. 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)
  7. Perl / Говнокод #4632

    −155

    1. 1
    $??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see

    Arigato, 15 Ноября 2010

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

    −171

    1. 1
    ms = decode_mail_headers(decodeUnknown(message.get_charset(), message.get('Subject', 'Created from e-mail'))).replace("Re: ", "").replace("Fwd: ","").replace("Fw: ", "").rep    lace("RE: ", "").replace("FW: ", "").strip()

    Веселые программисты не знают регэкспов в питоне.

    DiSH, 11 Ноября 2010

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

    +157

    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
    void QeLabel::mouseReleaseEvent(QMouseEvent *ev) {
    
        switch (ev->button()) {
        case Qt::LeftButton : {
                click++;
                click %=2;
                if (click == 0) {
                    emit dbl_clicked(id);
                }
                emit clicked(id);
                break;
            }
        default: break;
        }
    }

    сигналы на нажатие мыши

    onto, 09 Ноября 2010

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    private function trailing_slash_check($str)
         {
              if ((strrpos($str, '/') + 1) != strlen($str))
              {
                   $str = $str.'/';
              }
              
              return $str;
         }

    stasoft, 06 Ноября 2010

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

    −196

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    SELECT SQL_CALC_FOUND_ROWS h.hotel_id , h.class, h.review_score, hr.view_count, MIN(r.min_price) as min_price 
    FROM hotel_facility hf11, hotel_facility hf39, hotel h 
    LEFT JOIN hotels.room r ON r.hotel_id = h.hotel_id 
    LEFT JOIN hotels.hotel_reiting_our hr ON h.hotel_id = hr.hotel_id 
    WHERE h.is_closed != 1 AND city_id=2760 and h.hotel_id = hf11.hotel_id and h.hotel_id = hf39.hotel_id AND hf11.hotelfacilitytype_id = 11 AND hf39.hotelfacilitytype_id = 39 
    GROUP BY h.hotel_id 
    ORDER BY h.ranking DESC;

    rO_ot, 04 Ноября 2010

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