1. JavaScript / Говнокод #13155

    +150

    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
    //
        getMode: function(nMode) {
            switch (nMode) {
                case this.MODES.LEFT_BOOKEND:
                    return this.aModes[nMode];
                case this.MODES.RIGHT_BOOKEND:
                    return this.aModes[nMode];
                case this.MODES.BOTH_BOOKENDS:
                    return this.aModes[nMode];
                case this.MODES.NONE:
                default:
                    return this.aModes[this.MODES.NONE];
            }
        },

    Наверное уже боян, но вот же он, опять!

    https://github.com/scirelli/ExtjsBreadCrumbs/blob/master/js/ux/breadCrumbs.js

    Elvenfighter, 11 Июня 2013

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

    +130

    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
    public ICommand StartCommand
    {
        get
        {
            if (this.startCommand == null)
            {
                this.startCommand = new DelegateCommand(() =>
                {
                    Thread t = new Thread(StartServer);
                    t.Start();
                });
            }
    
            return this.startCommand;
        }
    }
    
    public ICommand EndCommand
    {
        get
        {
            if (this.endCommand == null)
            {
                this.endCommand = new DelegateCommand(() =>
                {
                    Thread t = new Thread(EndServer);
                    t.Abort();
                });
            }
    
            return this.startCommand;
        }
    }

    Команды для кнопочек запуска и остановки сервера

    NeoN, 11 Июня 2013

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

    +130

    1. 1
    throw new GnuPGException(String.Format("An error occurred while trying to execute command {0}.", command, exp));

    startrack, 11 Июня 2013

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

    +12

    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
    template <class ToPtr,class From>
    ToPtr DynamicCast (From f)
    {
      // static check if *ToPtr is derived from f
      (void)sizeof (static_cast<From> ((ToPtr)NULL));
      // lazy precalculation
      static bool castable = dynamic_cast<ToPtr> (f)!=NULL;
      static int offset =
        int ((char *)dynamic_cast<ToPtr> (f)-(char *)f);
      return castable? (ToPtr)((char *)f+offset) : NULL;
    }
    
    // usage: TBase *ptr1 = ...; TDerived *ptr2 = DynamicCast<TDerived *> (ptr1);

    Performance oriented dynamic_cast

    Artur, 11 Июня 2013

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

    −166

    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
    SELECT DISTINCT d.ageing as predicateid,
    		CONCAT(
    			TRIM(
    				TRIM(TRAILING "года" FROM 
    					TRIM(TRAILING "лет" FROM 
    						REPLACE(
    							REPLACE(
    								REPLACE(
    									REPLACE(
    										REPLACE(
    											REPLACE(
    												REPLACE(d.ageing, "не более ", "lte"), 
    											"не менее ","gte"),
    										"более ", "gt"),
    									"от ", "gt"),
    								"до ", "lt"),
    							"около ", "ab"), 
    						"менее ", "lt")
    					)
    				)
    			), 
    		"ag")  as nodecode, ...

    DIX315, 11 Июня 2013

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

    +10

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public ref class Form1 : public System::Windows::Forms::Form
    {
    private: char * StrToCharArray ( System::String ^ inStr )
    {
        pin_ptr<const wchar_t> wch_basename = PtrToStringChars( inStr );
        size_t convertedChars = 0; size_t  sizeInBytes = ((inStr->Length + 1) * 2);
        char * ch_basename = (char *)malloc(sizeInBytes);
        wcstombs_s(&convertedChars, ch_basename, sizeInBytes, wch_basename, sizeInBytes);
     return ch_basename;
    }
    }

    C++/CLI

    sokol, 11 Июня 2013

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

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    /**
         * @return the timeout from the URL, in milliseconds
         */
        private static long timeout(Properties props)

    Из драйвера JDBC PostgreSQL.

    Lavir_the_Whiolet, 11 Июня 2013

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

    +179

    1. 1
    2. 2
    3. 3
    4. 4
    public static function getCurrentYear()
    {
            return '2013';
    }

    Сейчас перебираю один класс со статическими методами и, вот, наткнулся на это. Не помню как и когда это написал :/

    coll3ctor, 11 Июня 2013

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    /* Я решил не выбирать какой-то определенный код, а просто запостить сцыл на гитхаб. 
    Ах да, свежие коммиты все же есть, так что, за говнокодом можно наблюдать "в прямом эфире"! */
    
    да прибудет с вами "<?php die;"

    https://github.com/mpak2/mpak.su/blob/master/include/mpfunc.php

    nkarakin, 11 Июня 2013

    Комментарии (35)
  10. C++ / Говнокод #13146

    +16

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    #define Throw(exc, msg) do {  \
       std::stringstream exc_str; \
       exc_str << __FILE__ << ":" << __LINE__ \
       << ": " << __func__ << "(): " << msg;  \
       throw exc(exc_str.str()); \
       } while(0)
    
    Throw(std::runtime_error, "test");

    terminate called after throwing an instance of 'std::runtime_error'
    what(): main.cpp:22: main(): Error

    Как вам?

    an0nym, 10 Июня 2013

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