1. Java / Говнокод #3554

    +82

    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
    //i dont know full description of this errors. i just copied it from official specification :)
        String[] eType =  new String[] {
            "Pending communication transaction in progress (0x20)",
            "Specified mailbox queue is empty (0x40)",
            "Request failed (i.e. specified file not found) (0xBD)",
            "Unknown command opcode (0xBE)",
            "Insane packet (0xBF)",
            "Data contains out-of-range values (0xC0)",
            "Communication bus error (0xDD)",
            "No free memory in communication buffer (0xDE)",
            "Specified channel/connection is not valid (0xDF)",
            "Specified channel/connection not configured or busy (0xE0)",
            "No active program (0xEC)",
            "Illegal size specified (0xED)",
            "Illegal mailbox queue ID specified (0xEE)",
            "Attempted to access invalid field of a structure (0xEF)",
            "Bad input or output specified (0xF0)"
        };

    перевод: Я не знаю, что все эти ошибки означают. Я просто скопировал это из оффициальной документации.
    всясуть жаба-кодеров.

    danilissimus, 23 Июня 2010

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

    +174

    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
    signed ToBool(signed b){unsigned t=b;return ( ((t<<0)>>31)  |  ((t<<1) >>31)  |  ((t<<2) >>31)  |  ((t<<3) >>31)  |  ((t<<4) >>31) | ((t<<5) >>31) | ((t<<6) >>31) | ((t<<7) >>31) | ((t<<8) >>31) | ((t<<9) >>31) | ((t<<10) >>31) | ((t<<11) >>31) | ((t<<12) >>31) | ((t<<13) >>31) | ((t<<14) >>31) | ((t<<15) >>31) | ((t<<16) >>31) | ((t<<17) >>31) | ((t<<18) >>31) | ((t<<19) >>31) | ((t<<20) >>31) | ((t<<21) >>31) | ((t<<22) >>31) | ((t<<23) >>31) | ((t<<24) >>31) | ((t<<25) >>31) | ((t<<26) >>31) | ((t<<27) >>31) | ((t<<28) >>31) | ((t<<29) >>31) | ((t<<30) >>31) | ((t<<31) >>31) );};
    signed NotBool(signed b){/*signed b=ToBool(b);*/unsigned t=(~b)<<31;return t>>31;};
    signed isZero(signed a){return NotBool(ToBool(a));};
    signed isNotZero(signed a){return NotBool(isZero(a));};
    signed isSign(signed a){unsigned t=a;return (t>>31);};signed isNotSign(signed a){return NotBool(isSign(a));};
    signed isEqual(signed a,signed b){	return isZero(a-b);};
    signed isNotEqual(signed a,signed b){return NotBool(isEqual(a,b));};
    signed isLess(signed a,signed b){return isSign(a-b);};
    signed isEqualMore(signed a,signed b){return NotBool(isLess(a,b));};
    signed isEqualLess(signed a,signed b){return isEqual(a,b)|isLess(a,b);};
    signed isMore(signed a,signed b){return NotBool(isEqualLess(a,b));};
    signed Equal(signed a,signed b,signed success,signed fail){signed t=isEqual(a,b);return (success*t)+(fail*NotBool(t));};
    signed NotEqual(signed a,signed b,signed success,signed fail){signed t=NotBool(isEqual(a,b));return (success*t)+(fail*NotBool(t));};
    signed Less(signed a,signed b,signed success,signed fail){signed t=isLess(a,b);return (success*t)+(fail*NotBool(t));};
    signed More(signed a,signed b,signed success,signed fail){signed t=isMore(a,b);return (success*t)+(fail*NotBool(t));};
    signed EqualLess(signed a,signed b,signed success,signed fail){signed t=isEqualLess(a,b);return (success*t)+(fail*NotBool(t));};
    signed EqualMore(signed a,signed b,signed success,signed fail){signed t=isEqualMore(a,b);return (success*t)+(fail*NotBool(t));};

    Вот такое форматирование... Хотя функции какие-то сомнительные...

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

    Комментарии (33)
  3. 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)
  4. C++ / Говнокод #3551

    +167

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

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

    Lexey, 23 Июня 2010

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

    −140

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

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

    raorn, 23 Июня 2010

    Комментарии (50)
  9. 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)
  10. 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)