1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #13871

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function refreshPaymentStatus() {
    }
    
    refreshPaymentStatusJob();
    
    function refreshPaymentStatusJob() {
        setInterval("refreshPaymentStatus()", 10000);
    }

    Бесят люди которые, будучи обмануты кажущейся простотой JS, пишут такие конструкции "по привычке". Job он, @#$%, завёл. А Scheduler, интересно, где забыл? А SchedulerManager? А SchedulerManagerFactory? Зато не забыл передать строкой первый аргумент в setInterval, молодец.

    madhead, 30 Сентября 2013

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

    +2

    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
    double vvod (double a1, double a2, double a3) {
     
    // a1=a a2=b a3=c
     
    	cout<<"Введите значение коэфицента a: ";
    	cin>>a1;
    	cout<<endl;
    	cout<<"Введите значение коэфицента b: ";
    	cin>>a2;
    	cout<<endl;
    	cout<<"Введите значение коэфицента c: ";
    	cin>>a3;
    	cout<<endl;
    	return (a1);
    	return (a2);
    	return (a3);
    }

    Оказывается в С++ можно возвращать 3 значения из функции
    http://ideone.com/tGWRpl - полная версия.

    pabloid, 05 Сентября 2013

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

    +8

    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
    #include <pthread.h>
    template<class T = long long>
    class AtomicCounter
    {
        public:
            explicit AtomicCounter( T value = 0 ): _count( value ) { pthread_spin_init( &_lock, PTHREAD_PROCESS_PRIVATE );};
            ~AtomicCounter()  { pthread_spin_destroy( &_lock );    };
    
            T operator++(int) volatile {  return interlockFetchAndAdd( 1 );      };
            T operator--(int) volatile {  return interlockFetchAndAdd( -1 );     };
            T operator() ()   volatile {  return interlockFetchAndAdd( 0 );      }
    
        private:
            volatile T    _count;
            pthread_spinlock_t _lock;
    
            T interlockFetchAndAdd( int delta ) volatile
            {
                T x = 0;
                pthread_spin_lock( &_lock );
                x = _count;
                _count += delta;
                pthread_spin_unlock(&_lock);
                return x;
            }
    };

    Принцип наименьшего удивления, говорите

    roman-kashitsyn, 26 Июля 2013

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

    +25

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    bool Channel::applyPreprocessorSettings()
    {
    	if (captureDeviceID_.empty() || !isSafeToChangeSettingsNow())
    		CHANNEL_LOG("deferring applyPreprocessorSettings()");
    		needApplyPreprocessorSettings_ = true;
    		return false;
    
    	// ... (куча кода)
    	
    	return true;
    }

    Никогда - слышите, НИКОГДА! - не пишите на C++ одновременно с питоном.

    Kirinyale, 09 Апреля 2013

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

    +19

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    struct BufInfo 
    {
    	const tbal::Bitmap &src, &dst;
    	int y1, y2;
    	BufInfo (const tbal::Bitmap &scr, const tbal::Bitmap &dst, int y1, int y2) : src(src), dst(dst), y1(y1), y2(y2) {}
    };

    Как можно проебать час жизни...

    TarasB, 20 Марта 2013

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

    +11

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    typedef void Start1(void);
    struct Kernel
    {
        Start1 Start;
    } kernel;
     
    void Kernel::Start(void)
    {
     
    }

    Как всегда оттуда.

    LispGovno, 06 Ноября 2012

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

    +21

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    int main()
    {
        unsigned int input[65536];
        int counter=0;
        while(scanf("%u", &(input[counter++])) != EOF);
        while (counter-- > 0) printf("%.4f\n", sqrt((double)(input[counter])));
        return 0;
    }

    Реализация задачи http://acm.timus.ru/problem.aspx?space=1&num=1001

    kganker, 19 Октября 2012

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

    +57

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($atributId){
          $sql = "UPDATE directory_atributes SET name = '$newName' WHERE id = $atributId LIMIT 1";
          $db-> Query($sql);
          die();
     } else{
          die();
     }

    Депрессивное программирование. В любом случае ты умрёшь.

    somnambulism, 01 Октября 2012

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

    +126

    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
    double fact(int value)
            {
                switch (value)
                {
                    case 0:
                        return 1;
                        break;
                    case 1:
                        return 1;
                        break;
                    default:
                        return value * fact(value - 1);
                        break;
                }
            }

    Вычисление факториала

    zzANDREYzz, 04 Апреля 2012

    Комментарии (51)
  11. C++ / Говнокод #8853

    +997

    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
    Can you think of an algorithm that performs the below:
    “The Big Brown Fox”    	     => “Fox Brown Big The”
    “How are you?”                 => “you? are How”
    
    std::string reverse_words( const std::string& str )
    {
      std::string result;
      result.reserve( str.length() );
      
      size_t word_begin = 0;
      while( word_begin < str.length() )
      {
        const size_t pos = str.find_first_of( ' ', word_begin );
        pos = (pos != string::npos) ? pos : str.length();
        std::string word = str.substr( word_begin, pos-word_begin );
        word_begin = pos + 1;
    
        if (result.length() > 0)
        {
          word.append( 1, ' ');
        }
        result.insert( 0, word );
      }
      return result;
    }

    высрал буквально 5 минут назад
    inplace версию чего-то влом писать для домашнего теста, да и кода в ней будет больше, но работать она должна быстрее за счет отсутствия аллокаций
    но писать надо, так как отправлять такое как-то стыдно

    pushkoff, 17 Декабря 2011

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