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

    +170

    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
    //Файл teamWorkFile.h:
    static int teamWork(int e)
    {
    #if N==0
    	return 0;
    #elif N==1
    	return Work52(e+1);
    #elif
    	return WorkN(N);
    #endif
    };
    
    //Файл teamWork.h:
    //...
    #define MaxProc 6
    typedef int (*ProcTypeTeamWork)(int e);
    ProcTypeTeamWork Proc[MaxProc]; 
    #define N 0
    #define teamWork ProcName0
    #include "teamWorkFile.h"
    #undef teamWork
    #undef N
    #define N 1
    #define teamWork ProcName1
    #include "teamWorkFile.h"
    #undef teamWork
    #undef N
    int InitMultiProc()
    {
    	Proc[0]=ProcName0;
    	Proc[1]=ProcName1;
    	Proc[2]=ProcName1;
    	Proc[4]=ProcName0;
    	Proc[5]=ProcName1;
    	return 0;
    };
    
    //Файл teamWorkLib.cpp:
    #include "teamWork.h"
    //...
    InitMultiProc();
    ProcTypeTeamWork SuperProc=Proc[5];
    //Дальше в этом файле вызовы в стиле Proc[i](e);, SuperProc(255); и тд...

    Удивительный код состоит из 3х файлов(teamWorkLib.cpp, teamWork.h, teamWorkFile.h), но он того стоит.

    Говногость, 23 Июня 2010

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

    +167

    1. 1
    2. 2
    3. 3
    bool dicLoaded_ = false;
    ....
    dicLoaded_ = dicLoaded_?false:true;

    Еще один перл из кандидатских заданий. Любителям тернарных операторов посвящается.

    Lexey, 23 Июня 2010

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

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #define ItemType char
    #define SecondItemType unsigned
    class Doubler
    {
    	ItemType _i1_;
    	SecondItemType _i2_;
    	//...
    	//Дальше идёт много функций класса, использующие ItemType и SecondItemType.
    	//...
    };

    Говногость, 23 Июня 2010

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

    +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
    class ControlerSingleton
    {
    private:
    	static int ControlCode;
    	static bool disaPear;
    	static int ArraySize;
    	//...
    	void Constructor()
    	{
    		//...
    		ArraySize=sizeof(masi)/sizeof(masi[0]);
    		disaPear=Pear();
    		threadRAII.Wait();
    		ControlCode=threadRAII.result();
    		//...
    	};
    	static int construct=Constructor();
    public:
    	const bool Pear()
    	{
    	//...
    };

    Своеобразный "конструктор" в классе синглтона.

    Говногость, 23 Июня 2010

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

    +163

    1. 1
    smart_ptr<const AbstractElanos> pointy;struct Intializer{Intializer(void){pointy=new Elanos;};}initer;

    Согласно проектного решения

    smart_ptr<const AbstractElanos> pointy=new Elanos;

    писать нельзя. Конструктор из поинтера не определён.
    Ну а народ любит размещать данные глобально и сразу инициализировать. Последствия весьма наглядны.

    Говногость, 23 Июня 2010

    Комментарии (21)
  6. bash / Говнокод #3547

    −140

    1. 1
    OWNER=`ls -l $i | awk '{ print $3 }'`

    initscripts-8.45.30-2.el5, не хрен собачий...

    raorn, 23 Июня 2010

    Комментарии (50)
  7. SQL / Говнокод #3546

    −857

    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
    procedure xxx_procedure
    is
    --   lngIDVidPP Number;
       sSQL       varchar2(4000);
    begin
    sSQL := '';
    sSQL := sSQL || ' Declare ';
    sSQL := sSQL || '    lngIDVidPP Number; ';
    sSQL := sSQL || '    lngColRec  Number; ';
    sSQL := sSQL || '    strTypeProc Varchar2(255); ';
    sSQL := sSQL || ' BEGIN ';
    sSQL := sSQL || ' for rec in (select f.param2 , A.idpp, pp.crastr, pp.cvector, a.param1, a.et, a.tet ';
    sSQL := sSQL || '  from table1 e, T_IDPP@' || 'app' || '_' ||'xxx' || ' a, table2 f, ';
    sSQL := sSQL || '   t_pp_card@' || 'app' || '_' || 'xxx' || ' pp,  refitem r';
    sSQL := sSQL || '  where ';
    sSQL := sSQL || '   e.param1 = a.param1 ';
    sSQL := sSQL || '   and e.id_building = F.ID_BUILDING ';
    sSQL := sSQL || '   and F.FLOOR_NUMBER = a.et ';
    sSQL := sSQL || '   and R.REFERENCEID = 2019 and R.ITEMID = F.ID_FLOOR_TYPE';
    sSQL := sSQL || '   and R.CODE = a.tet';
    sSQL := sSQL || '   and a.idpp = pp.cidpp)';
    sSQL := sSQL || '  loop ';
    sSQL := sSQL || '     lngColRec := 0; ';
    sSQL := sSQL || '     lngIDVidPP := 0; ';
    sSQL := sSQL || '     SELECT COUNT(*) INTO lngColRec FROM T_PROCESS_PP@' || 'app' || '_' || 'xxx || ' Z ';
    sSQL := sSQL || '                     WHERE Z.PPP_UNOM = rec.param1 AND Z.PPP_ET = rec.et AND Z.PPP_TET = rec.tet; ';
    sSQL := sSQL || '     if lngColRec = 0 then ';
    sSQL := sSQL || '        if BITAND(rec.crastr, 8) <> 0 and BITAND(rec.cvector, 8) <> 0 then ';
    sSQL := sSQL || '           lngIDVidPP := 50868; ';
    sSQL := sSQL || '        else ';
    sSQL := sSQL || '           if BITAND(rec.crastr, 8) <> 0 then ';
    sSQL := sSQL || '              lngIDVidPP := 50866; ';
    sSQL := sSQL || '           else ';
    sSQL := sSQL || '              lngIDVidPP := 50867; ';
    sSQL := sSQL || '           end if; ';
    sSQL := sSQL || '        end if; ';
    sSQL := sSQL || '        update table2 f ';
    sSQL := sSQL || '            set f.xx      = rec.idpp, ';
    sSQL := sSQL || '                f.xxx   = lngIDVidPP, ';
    sSQL := sSQL || '                f.xxxx = 54554 ';
    sSQL := sSQL || '          where f.xxxxx = rec.id_floor; ';
    sSQL := sSQL || '     else  '; --if lngColRec > 0 then
    sSQL := sSQL || '          strTypeProc := Null; ';
    sSQL := sSQL || '          SELECT Y.PH_ACTION_KEY INTO strTypeProc ';
    sSQL := sSQL || '            FROM T_PROCESS_HEAD@' || 'app' || '_' || 'SGP' || ' Y ';
    sSQL := sSQL || '            WHERE ';
    sSQL := sSQL || '                 Y.PHID IN (SELECT X.PPP_PHID ';
    ...... 10 строк вырезано из-за ограничения 4000символов
    sSQL := sSQL || '               if BITAND(rec.crastr, 8) <> 0 and BITAND(rec.cvector, 8) <> 0 then ';
    sSQL := sSQL || '                  lngIDVidPP := 50868; ';
    sSQL := sSQL || '               else ';
    sSQL := sSQL || '                  if BITAND(rec.crastr, 8) <> 0 then ';
    sSQL := sSQL || '                     lngIDVidPP := 50866; ';
    sSQL := sSQL || '                  else ';
    sSQL := sSQL || '                     lngIDVidPP := 50867; ';
    sSQL := sSQL || '                  end if; ';
    sSQL := sSQL || '               end if; ';
    sSQL := sSQL || '                  update table3 f ';
    sSQL := sSQL || '                     set f.ID_PLANE_G = rec.idpp, ';
    sSQL := sSQL || '                     f.id_plane_scan = lngIDVidPP, ';
    sSQL := sSQL || '                     f.id_status_plane = 54552 ';
    sSQL := sSQL || '               where f.param1 = rec.param1; ';
    sSQL := sSQL || '           ELSE ';
    sSQL := sSQL || '                  update table3 f ';
    sSQL := sSQL || '                 set f.id_status_plane = 54552 ';
    sSQL := sSQL || '               where f.param1 = rec.param1; ';
    sSQL := sSQL || '           END IF; ';
    sSQL := sSQL || '     end if; ';  --if lngColRec > 0 then
    sSQL := sSQL || '   end loop;';
    sSQL := sSQL || '  null;';
    sSQL := sSQL || '  end;';
    
    EXECUTE IMMEDIATE sSQL;
            dbms_output.put_line ('Процедура xxx_procedure успешно создана');
    EXCEPTION
      WHEN OTHERS THEN dbms_output.put_line('Ошибка создания xxx_procedure. ' || SQLERRM);
    end;

    В связи с NDA названия изменены.

    kamapcuc, 23 Июня 2010

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

    +120

    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
    protected void GridView1_PreRender(object sender, EventArgs e)
        {         
             System.Drawing.Color OddGridColor = new System.Drawing.Color();
             OddGridColor = System.Drawing.Color.FromArgb(0xD3, 0xDE, 0xEF);
             System.Drawing.Color EvenGridColor = new System.Drawing.Color();
             EvenGridColor = System.Drawing.Color.FromArgb(0xEC, 0xE9, 0xD8);
    
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                      if (i % 2 == 1)
                      {
                          GridView1.Rows[i].BackColor = OddGridColor;
                      }
                      else
                      {
                          GridView1.Rows[i].BackColor = EvenGridColor;
                      }
                 }
        }

    the way of change GridView color through one ...
    Why do not use <AlternatingRowStyle> ?!!

    O_O, 23 Июня 2010

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

    +102

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    case dlg.sort.ItemIndex of
             0: Qry.SQL.Add('ORDER BY b.nn_rez;');
             1: if dlg.view.ItemIndex=1 then Qry.SQL.Add('ORDER BY c.prod_code;')
                                                     else Qry.SQL.Add('ORDER BY c.kod_okp;');
             2: if dlg.view.ItemIndex=1 then Qry.SQL.Add('ORDER BY c.res_name;')
                                                     else Qry.SQL.Add('ORDER BY c.naimres;');
         end;

    Твой кролик писал!
    кто-то явно мастер на выдумки

    Grizzly, 23 Июня 2010

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

    +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
    $pass = 12345; 
    
    if (!isset($_POST['pass'])) { 
    $pass = $_GET['pass']; 
    } 
    else 
    { 
    $pass = $_POST['pass']; 
    } 
    if ($pass !== $pass) { 
    
    echo '<form method = "post" action = "pass.php?"> 
          Пароль:<br/> 
          <input name = "pass" type = "password"/><br/> 
          <input type = "submit" value = "OK"/></form>'; 
          } 
          echo 'Тебе сюда можна'; 
          ....блаблабла  
          } else { 
          echo 'Низя :)'; 
          break; 
          } 
          }

    >>Надо чтобы проверял если там дата[2] не пуста то показал форму инпут.
    жесть)))

    Aligan, 23 Июня 2010

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