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

    +65

    1. 1
    BigInteger.ONE

    LispGovno, 17 Марта 2014

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

    +129

    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
    class WorkDBF
        {
            private OdbcConnection _connection = null;
            public DataTable Execute(string command)
            {
                DataTable dt = null;
                if (_connection != null)
                {
                    try
                    {
                        _connection.Open();
                        dt = new DataTable();
                        System.Data.Odbc.OdbcCommand oCmd = _connection.CreateCommand();
                        oCmd.CommandText = command;
                        dt.Load(oCmd.ExecuteReader());
                        _connection.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
                return dt;
            }
            public DataTable GetAll(string dbpath)
            {
                return Execute("SELECT * FROM " + dbpath);
            }
            public WorkDBF()
            {
                this._connection = new System.Data.Odbc.OdbcConnection();
                _connection.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};" +
                    "SourceType=DBF;Exclusive=No;" +
                    "Collate=Machine;NULL=NO;DELETED=NO;" +
                    "BACKGROUNDFETCH=NO;";
            }
        }

    orozov, 17 Марта 2014

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

    +70

    1. 1
    newValue = (value.equals("1") ? true : false);

    тернарный оператор головного мозга

    evg_ever, 17 Марта 2014

    Комментарии (0)
  4. Java / Говнокод #15500

    +68

    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
    private Date value;
    private SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
    private SimpleDateFormat sdfshort = new SimpleDateFormat("dd.MM.yyyy");
    
    void setValue(String value) {
    	try {
    		if (value.length() >= 18)
    			this.value = sdf.parse(value);
    		else
    			this.value = sdfshort.parse(value);
    	} catch (ParseException e) {
    		this.value = sdfshort.parse(value);
    	}
    }

    evg_ever, 17 Марта 2014

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

    +101

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function GetBit(numBit,Val: integer):boolean;
    var
      i: integer;
    begin
      i := round(power(2,numBit-1));
      result := (i and Val) >0;
    end;

    Суровые и беспощадные битовые операции в дельфи. Причем коллега, у которого я это нашел неплохие программы пишет, во всяком случае по части удобства интерфейса мне до него далеко. Но иногда такие перлы встречаются.

    kipar, 17 Марта 2014

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

    +17

    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
    // base class for objects that need to be initialized
    //
    struct Initializable
    {
    protected:
    
    	inline void OneTimeInit()
    	{
    #if _DEBUG_BUILD
    		ASSERT(!m__hasBeenIsInitialized);
    		m__hasBeenIsInitialized = true;
    #endif // _DEBUG_BUILD
    	}
    
    	inline void OneTimeDestroy()
    	{
    #if _DEBUG_BUILD
    		ASSERT(m__hasBeenIsInitialized);
    		m__hasBeenIsInitialized = false;
    #endif // _DEBUG_BUILD
    	}
    
    	inline void CheckInitialized()
    	{
    #if _DEBUG_BUILD
    		mxBREAK_IF( !m__hasBeenIsInitialized );
    #endif // _DEBUG_BUILD
    	}
    
    	inline Initializable()
    	{
    #if _DEBUG_BUILD
    		m__hasBeenIsInitialized = false;
    #endif // _DEBUG_BUILD
    	}
    
    	inline ~Initializable()
    	{
    #if _DEBUG_BUILD
    		ASSERT(!m__hasBeenIsInitialized);
    #endif // _DEBUG_BUILD
    	}
    
    private:
    #if _DEBUG_BUILD
    	bool	m__hasBeenIsInitialized;
    #endif // _DEBUG_BUILD
    };
    
    template< class KLASS >	// where KLASS : TGlobal<KLASS>, Initializable
    struct DependsOn
    {
    protected:
    	DependsOn()
    	{
    		ASSERT( KLASS::HasInstance() );
    		ASSERT( KLASS::Get().IsInitialized() );
    	}
    };
    
    template< class KLASS >	// where KLASS : TGlobal<KLASS>
    struct DependsOnGlobal
    {
    protected:
    	DependsOnGlobal()
    	{
    		ASSERT( KLASS::HasInstance() );
    		//ASSERT( KLASS::Get().IsInitialized() );
    	}
    };

    Базовый класс для дебажной проверки того, был ли инициализирован конкретный объект.
    Этот бред находился в самой древней кодобазе, сейчас нигде не используется. Удаляю.

    ThEn00bishProGrammar, 16 Марта 2014

    Комментарии (1)
  7. JavaScript / Говнокод #15491

    +166

    1. 1
    window.__debugMode = true; // Don't turn it off

    vk.com/js/al/common.js

    UnnamedUser, 15 Марта 2014

    Комментарии (3)
  8. Pascal / Говнокод #15488

    +87

    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
    delim:=0;
    result:='';
    resulttemp:='';
    otv1:=trunc(rez);
    ott2:=rez-otv1;
    while otv1>=s1 do
    begin
    	delim:=delim+1;
    	r1:=otv1 div s1;
    	r2:=otv1 mod s1;
    	otv1:=r1;		
    	if (r2>=0) and (r2<=9) then
    		str(r2,resulttemp);			
    	if r2=10 then resulttemp:='a';
    	if r2=11 then resulttemp:='b';
    	if r2=12 then resulttemp:='c';
    	if r2=13 then resulttemp:='d';
    	if r2=14 then resulttemp:='e';
    	if r2=15 then resulttemp:='f';		
    	result:=result+resulttemp;
    end;	
    if (otv1>=0) and (otv1<=9) then
    	str(otv1,resulttemp);	
    if otv1=10 then resulttemp:='a';
    if otv1=11 then resulttemp:='b';
    if otv1=12 then resulttemp:='c';
    if otv1=13 then resulttemp:='d';
    if otv1=14 then resulttemp:='e';
    if otv1=15 then resulttemp:='f';	
    result:=result+resulttemp;
    delim:=length(result);
    resulttemp:=result;
    for otv1:=1 to delim do
    	result[otv1]:=resulttemp[delim+1-otv1];

    Перевод числа из десятичной системы счисления в систему счисления с основанием s1

    n924, 15 Марта 2014

    Комментарии (7)
  9. Си / Говнокод #15487

    +133

    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
    if (other && other->client && other->s.number < MAX_CLIENTS)
    		{//player touched me
    			/*
    			char *text;
    			qboolean	keyTaken;
    			//give him my key
                            ...
    
    			*/
    			//rwwFIXMEFIXME: support for goodie/security keys?
    			/*
    			if ( keyTaken )
    			{//remove my key
    				NPC_SetSurfaceOnOff( self, "l_arm_key", 0x00000002 );
    				self->message = NULL;
    				//FIXME: temp pickup sound
    				G_Sound( player, G_SoundIndex( "sound/weapons/key_pkup.wav" ) );
    				//FIXME: need some event to pass to cgame for sound/graphic/message?
    			}
    			//FIXME: temp message
    			gi.SendServerCommand( NULL, text );
    			*/
    		}

    FIXMEFIXMEFIXME... Да ну нахуй, лучше все закомментим.

    gost, 15 Марта 2014

    Комментарии (38)
  10. JavaScript / Говнокод #15486

    +154

    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
    var SE = document.getElementsByTagName("a");
    for (var i = 0; i < SE.length; i++)
    {
        if (SE[i].href.indexOf('http://www.govnokod.ru/ratings/comment/') == 0
    	    && SE[i].href.indexOf('on') != -1)
    	{
    		plusIT(SE[i].href);
    		console.log(SE[i].href);
    	}
    }
    
    function plusIT(ID)
    {
    	$.get(
        ID,
        {},
        function(x) {
        });
    }

    gost, 15 Марта 2014

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