1. C++ / Говнокод #2592

    +53.4

    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
    void __fastcall TUsers::DBG2DrawColumnCell(TObject *Sender,
          const TRect &Rect, int DataCol, TColumn *Column,
          TGridDrawState State)
    {
    
        const int iIsChecked[2] = {DFCS_BUTTONCHECK | DFCS_FLAT, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT};
        int DrawState;
        TRect DrawRect;
        if (State.Contains(gdFocused) == true)
        {
            if (Column->Field->FieldName == dbchkApplyDoc2->DataField)
            {
                ShowMessage("Зацикливает :( ");
                ShowMessage("Эта надпись будет повторяться бесконечно - почему ???");
            }
        }
        else
        {
            if (Column->Field->FieldName == dbchkApplyDoc2->DataField)
            {
                DrawRect = Rect;
                InflateRect(&DrawRect, -2, -2); // Matters ?
                DrawState = iIsChecked[Column->Field->AsBoolean];
                DBG2->Canvas->FillRect(Rect);
                DrawFrameControl(DBG2->Canvas->Handle, &DrawRect, DFC_BUTTON, DrawState);
            }
        }
    }

    Почему

    Nemerle, 11 Февраля 2010

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

    +68.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // I'VE SO FUCKED CONVERTING THOSE FUCKING TYPES OF STUPID DATA
    		// TAKE IT, FUCKING STRAUSTRUP AND K&R!!!!!!!!!!!
    		if (text[i]=='1') (intarray[i]=1);
    		if (text[i]=='2') (intarray[i]=2);
    		if (text[i]=='3') (intarray[i]=3);
    		if (text[i]=='4') (intarray[i]=4);
    		if (text[i]=='5') (intarray[i]=5);
    		if (text[i]=='6') (intarray[i]=6);
    		if (text[i]=='7') (intarray[i]=7);
    		if (text[i]=='8') (intarray[i]=8);
    		if (text[i]=='9') (intarray[i]=9);
    		if (text[i]=='0') (intarray[i]=0);

    i0ngunn3r, 11 Февраля 2010

    Комментарии (17)
  3. Python / Говнокод #2590

    −89.3

    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
    import sys
    import subprocess
    from PyQt4 import QtCore, QtGui
    
    class AboutWindow(QtGui.QDialog):
        def __init__(self, parent=None):
            super(AboutWindow, self).__init__(parent)
    
            ## <говногод>
            class QHyperlinkLabel(QtGui.QLabel):
                def mousePressEvent(self,pos):
                    subprocess.call(["explorer.exe",'http:\\\\mysite.com'])
    
            hyperLink = QHyperlinkLabel("Гиперрсылка")
            ## </говногод>
    
            layoutBase = QtGui.QGridLayout()
            layoutBase.addWidget(hyperLink,0,0)
            self.setLayout(layoutBase)
    
    if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        dlg=AboutWindow(None)
        dlg.exec_()

    Такой вот говнокостыль.
    Щелчок по "гиперссылке" таки открывает ее в explorer'е.

    Кстати, кто знает адекватное решение для ПиКуТи, делитесь же.

    anon_1298, 11 Февраля 2010

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

    −117.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    ТекВрем = Час(ТекущаяДата())*60+Минута(ТекущаяДата());
    ВремКурсов = 60;
    Если ТекВрем >= ВремКурсов Тогда
    	ВремКурсов = ВремКурсов + 24*60 - ТекВрем;
    Иначе
    	ВремКурсов = ВремКурсов - ТекВрем;
    КонецЕсли;
    ВремКурсов = 1;
    ПодключитьОбработчикОжидания("ЗагрузкаВалютИПересчетУЕ", ВремКурсов*60);

    Вычисляем ВремКурсов, а затем присваиваем этой переменной единицу и умножаем на 60. Рациональность, чорт побери! :-D

    KingOfShit, 11 Февраля 2010

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

    +170.6

    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
    <?php
      foreach ($_REQUEST as $s => $v)
      {
        $s = strtolower($s);
        $_REQUEST[$s] = $v;
      }
    
      $aaa = urlencode(urldecode($_REQUEST['aaa']));
      $q = urlencode(urldecode($_REQUEST['q']));
      $bbb = urldecode($_REQUEST['bbb']);
      $ccc = intval($_REQUEST['ccc']);
    
      $ddd = intval($_REQUEST['ddd']);
      if ($ddd > 16384)
        $ddd = 0;
      if (isset($_REQUEST['ddd2']))
        $ddd2 = trim(strtolower(urldecode($_REQUEST['ddd2'])));
      else
        $ddd2 = trim(strtolower(urldecode($_REQUEST['ddd'])));
    
      if (!preg_match('/^[0-9a-z_\-]*$/i', $ddd2))
      {
        $ddd2 = preg_replace('/[^0-9a-z_\-]+/i', '', $ddd2);
        if (strlen($ddd2) > 16)
          $ddd2 = substr($ddd2, 0, 16);
      }
      if (strlen($ddd2) <= 16 && strlen($ddd2) >= 1)
      {
        $ddd = 0;
      } else
      {
        $ddd2 = '';
      }
    ?>

    govnokod, 10 Февраля 2010

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

    +142.6

    1. 1
    myDataSet.Tables[0].DataSet.GetXml();

    need XML Data Source from XML for making dynamic ASP:Menu
    This code makes DataSource as a Parent element and elements from sql as a Children
    I need Parent Elements only from my sql. To make it like a Horizontal TabSet . . .

    Nemerle, 10 Февраля 2010

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

    +75

    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
    import java.util.*;
     
    public class Shell {
        Shell(){
                   main();
            }
            private void main(){
             boolean flag=true;
                String c;
                   while(flag){
                      c=Kernel.stdin("#");
                         String out=exec(c);
                      Kernel.stdout(out);
              }
            }
            public static String exec(String cmd){
                 String tmp="";
                  Lib_parse.line(cmd," ");
               String c=Lib_parse.get(0).toLowerCase();
                    if(c=="help"){
                        tmp.concat("uname - get the OC version \n");
                          tmp.concat("echo - echo input phraze \n");
                    }
                    if(c=="uname"){
                       tmp.concat("L2ME Kernel v1.3 - Linux 2 Java ME (c) new_user \n");
             }
                    if(c=="echo"){
                        tmp.concat(cmd.substring(4,cmd.length()-1)+"\n");
                   }
            return tmp;
         }
    }

    Правда мило? :)

    Pyth_ON, 10 Февраля 2010

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

    −184.6

    1. 1
    return lib.formatters.__dict__[id].format(txt)

    Мы же не ищем легких путей, правда? В модуле formatters определен словарь, к которому мы таким образом обращаемся.

    Gukl, 10 Февраля 2010

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

    +175.4

    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
    function makeQuery($keywords, $item, $type="and")
    {
    	// Тут аффтар вестимо вырезает последовательности из больше чем одного пробела
            for ($i=0; $i<1000; $i++)
    	{
    		 $keywords=str_replace("  "," ", $keywords);
    	}
    	$keywords.=" ";
    	$que="";
            // А эта хуета вместо explode( " ", $keywords )
    	while (strpos($keywords, " "))
    	{
    		$que.=" $type $item like '%".substr($keywords, 0, strpos($keywords, " "))."%'";
    		$keywords=substr($keywords,strpos($keywords, " ")+1);
    	}
    return $que;
    }

    Функция генерит SQL для поиска. Нарыл в коде чужой чудо-цмски. Такой феерической реализации в жизни не встречал...

    Johnny, 10 Февраля 2010

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

    +164.5

    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
    if($s_r1>0){
    while($s_ww_1=mysql_fetch_object($s_q_1)){
    $row_repl1["id"]=$s_ww_1->id;
    $row_repl1["name"]=$s_ww_1->name;
    $row_repl1["nick"]=$s_ww_1->nick;
    if($s_ww_1->nick==''){
    $row_tpl1 = new FileTemplate($row_repl1, "TEMPL/shabl119.tpl");
    }else{
    $row_tpl1 = new FileTemplate($row_repl1, "TEMPL/shabl120.tpl");
    }
    $row_repl0["T_level1"].=$row_tpl1->parse();
    $row_repl1=array();
    }// end while
    @mysql_free_result($s_q_1);
    }//if
    $row_tpl0 = new FileTemplate($row_repl0, "TEMPL/shabl152.tpl");
    $row_tpl0->display();
    $row_repl0=array();
    }// end while
    @mysql_free_result($s_q);
    }//if
    }elseif($lnk1==47){
    $s_q=mysql_query("SELECT id, name, descr FROM experts WHERE id=$lnk2 LIMIT 1");
    $s_r1 = mysql_error() ? 0 : mysql_num_rows($s_q);
    if($s_r1>0){
    while($s_ww=mysql_fetch_object($s_q)){
    $row_repl["id"]=$s_ww->id;
    $row_repl["name"]=$s_ww->name;
    $row_repl["descr"]=$s_ww->descr;
    $row_tpl = new FileTemplate($row_repl, "TEMPL/shabl18.tpl");
    $row_tpl->display();
    $row_repl=array();
    }// end while
    @mysql_free_result($s_q);
    }//if
    }elseif($lnk1==54){
    $s_q=mysql_query("SELECT id, name, subtitle, type, number, doclevel, body, date, descr, txt, shows, prompt FROM documents WHERE id=$lnk2 LIMIT 1");
    $s_r1 = mysql_error() ? 0 : mysql_num_rows($s_q);
    if($s_r1>0){
    while($s_ww=mysql_fetch_object($s_q)){
    $row_repl["id"]=$s_ww->id;
    $row_repl["name"]=$s_ww->name;
    $row_repl["subtitle"]=$s_ww->subtitle;
    $row_repl["ParentType"]=$s_ww->type;
    $ParentType=$row_repl["ParentType"];
    $s_q2=mysql_query("select name as type_doctypes_name from doctypes where id=".$s_ww->type."");
    $s_n2 = mysql_error() ? 0 : mysql_num_rows($s_q2);
    if($s_n2>0){
    $s_w2=mysql_fetch_object($s_q2);
    $row_repl["type_doctypes_name"]=stripslashes($s_w2->type_doctypes_name);
    @mysql_free_result($s_q2);
    }//s_n2
    $row_repl["number"]=$s_ww->number;
    $row_repl["doclevel"]=$s_ww->doclevel;
    $s_q2=mysql_query("select name as doclevel_doclevels_name from doclevels where id=".$s_ww->doclevel."");
    $s_n2 = mysql_error() ? 0 : mysql_num_rows($s_q2);
    if($s_n2>0){
    $s_w2=mysql_fetch_object($s_q2);
    $row_repl["doclevel_doclevels_name"]=stripslashes($s_w2->doclevel_doclevels_name);
    @mysql_free_result($s_q2);
    }//s_n2
    $row_repl["body"]=$s_ww->body;
    $row_repl["date"]=mysqldate_to_str($s_ww->date);
    $row_repl["descr"]=$s_ww->descr;
    $row_repl["txt"]=$s_ww->txt;
    $row_repl["shows"]=intval($s_ww->shows)+1;
    @UpdateFCounter("documents","shows","copyshows","id",$s_ww->id);

    Использовано в коде одного из проектов, оставшихся на поддержку. Такой красоты там только в одном файле - около 8000 строк.

    karevn, 10 Февраля 2010

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