- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
function refreshPaymentStatus() {
}
refreshPaymentStatusJob();
function refreshPaymentStatusJob() {
setInterval("refreshPaymentStatus()", 10000);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+149
function refreshPaymentStatus() {
}
refreshPaymentStatusJob();
function refreshPaymentStatusJob() {
setInterval("refreshPaymentStatus()", 10000);
}
Бесят люди которые, будучи обмануты кажущейся простотой JS, пишут такие конструкции "по привычке". Job он, @#$%, завёл. А Scheduler, интересно, где забыл? А SchedulerManager? А SchedulerManagerFactory? Зато не забыл передать строкой первый аргумент в setInterval, молодец.
+2
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 - полная версия.
+8
#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;
}
};
Принцип наименьшего удивления, говорите
+25
bool Channel::applyPreprocessorSettings()
{
if (captureDeviceID_.empty() || !isSafeToChangeSettingsNow())
CHANNEL_LOG("deferring applyPreprocessorSettings()");
needApplyPreprocessorSettings_ = true;
return false;
// ... (куча кода)
return true;
}
Никогда - слышите, НИКОГДА! - не пишите на C++ одновременно с питоном.
+19
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) {}
};
Как можно проебать час жизни...
+11
typedef void Start1(void);
struct Kernel
{
Start1 Start;
} kernel;
void Kernel::Start(void)
{
}
Как всегда оттуда.
+21
#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
+57
if($atributId){
$sql = "UPDATE directory_atributes SET name = '$newName' WHERE id = $atributId LIMIT 1";
$db-> Query($sql);
die();
} else{
die();
}
Депрессивное программирование. В любом случае ты умрёшь.
+126
double fact(int value)
{
switch (value)
{
case 0:
return 1;
break;
case 1:
return 1;
break;
default:
return value * fact(value - 1);
break;
}
}
Вычисление факториала
+997
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 версию чего-то влом писать для домашнего теста, да и кода в ней будет больше, но работать она должна быстрее за счет отсутствия аллокаций
но писать надо, так как отправлять такое как-то стыдно