-
Лучший говнокод
- В номинации:
-
- За время:
-
-
+2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
#define CREATE_EVENT_LISTENER(_elname, arg1_type, arg1_name) \
class _elname : public EventListener \
{ \
private: \
class IContainer \
{ \
public: \
virtual void Call(arg1_type arg1_name) = 0; \
virtual ~IContainer() {} \
}; \
\
class FunctionContainer : public IContainer \
{ \
private: \
typedef void(*__CallbackPtr)(arg1_type); \
public: \
FunctionContainer(__CallbackPtr fn) \
{ \
this->fn = fn; \
} \
\
virtual void Call(arg1_type arg1_name) \
{ \
fn(arg1_name); \
} \
\
private: \
__CallbackPtr fn; \
}; \
\
template<class T, class Q> \
class MethodContainer : public IContainer \
{ \
public: \
MethodContainer(T method, Q _this) \
{ \
this->method = method; \
this->_this = _this; \
} \
\
virtual void Call(arg1_type arg1_name ) \
{ \
(_this->*method)(arg1_name); \
} \
\
private: \
T method; \
Q _this; \
}; \
public: \
typedef void(*__FN_CALLBACK)(arg1_type); \
\
_elname(__FN_CALLBACK fn) \
{ \
this->container = new FunctionContainer(fn); \
} \
\
template <class T, class Q> \
_elname(T method, Q _this) \
{ \
this->container = new MethodContainer<T, Q>(method, _this); \
} \
\
void Call(arg1_type arg1_name) \
{ \
container->Call(arg1_name); \
} \
\
virtual ~_elname() \
{ \
delete this->container; \
} \
private: \
IContainer* container; \
}; \
#define CREATE_EVENT(_ename, _elname, arg1_type, arg1_name) \
class _ename : public Event \
{ \
public: \
void AddListener(_elname* listener) \
{ \
Event::AddListener(listener); \
} \
\
void Handle(arg1_type arg1_name) \
{ \
for (size_t i = 0; i < this->listeners.size(); i++) \
{ \
((_elname*)listeners[i])->Call(arg1_name); \
} \
} \
\
void RemoveListener(_elname* listener) \
{ \
Event::RemoveListener(listener); \
} \
\
}; \
Я когда то это написал. Думал, это хорошая идея...
Полный файл: https://github.com/arhyme/CPP_EVENTS/blob/master/Event.h
Avery,
18 Июля 2016
-
+161
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
function UpdateTime() {
var CurrentTime = new Date();
var InputTime = document.getElementById('MyTime');
var InputDate = document.getElementById('MyDate');
sec=sec+1;
if(sec >=58)
{
if(min>59)
{
hour=hour+1;
min=0;
} else
{ min=min+1;
};
sec=0;
} else {
};
h = hour;
if ( h < 10 ) h = "0" + h;
m = min;
if ( m < 10 ) m = "0" + m;
s = sec;
if ( s < 10 ) s = "0" + s;
outString = h + ":" + m + ":" + s;
InputTime.innerHTML = outString;
outString = d + " ";
outString += month[mo] + " ";
outString += y;
InputDate.innerHTML = outString;
setTimeout("UpdateTime()",1000);
}
Надо было человеку время написать на сайте, текущее...
И ОНО сделало ЭТО.
И этот код встречается на каждой странице проекта. Постоянно 1 и тот же. А верстку лучше даже не смотреть....
Уже около часа не знаю с какой стороны подобраться к этому поделию(в основном к верстке)...
Dart_Sergius,
19 Июля 2014
-
+19
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
wstring& delphi::IntToStr(int integer, wstring& str)
{
if (0 == integer)
return str = L"0";
str.clear();
wstring sign(L"");
if (integer < 0)
{
sign = L"-";
integer = -integer;
}
else
sign = L"";
while (integer >= 1)
{
str.push_back( (integer % 10) + 48 );
integer /= 10;
}
str += sign;
std::reverse(str.begin(), str.end());
return str;
}
snw,
03 Июля 2014
-
+133
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
#ifndef ORDER32_H
#define ORDER32_H
#include <limits.h>
#include <stdint.h>
#if CHAR_BIT != 8
#error "unsupported char size"
#endif
enum
{
O32_LITTLE_ENDIAN = 0x03020100ul,
O32_BIG_ENDIAN = 0x00010203ul,
O32_PDP_ENDIAN = 0x01000302ul
};
static const union { unsigned char bytes[4]; uint32_t value; } o32_host_order =
{ { 0, 1, 2, 3 } };
#define O32_HOST_ORDER (o32_host_order.value)
#endif
Говнокод из http://stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine
Мало того, что писать в один тип из юниона и потом читать из другого это UB, так еще компилятор (в случае GCC) из
int main(void)
{return O32_HOST_ORDER == O32_LITTLE_ENDIAN;}
нагенерирует код
main:
xor eax, eax
cmp DWORD PTR o32_host_order[rip], 50462976
sete al
ret
o32_host_order:
.byte 0
.byte 1
.byte 2
.byte 3
т.е. всякий раз, когда надо узнать endianess, мы лезем в константную статическую переменную и сравниваем ее с константой
j123123,
08 Апреля 2014
-
+142
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
static OSStatus
SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams,
uint8_t *signature, UInt16 signatureLen)
{
OSStatus err;
...
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;
...
Говно с яблочным привкусом.
http://habrahabr.ru/post/213525/
P.S.: Не уверен Си это или плюсы.
Vindicar,
24 Февраля 2014
-
+136
- 1
- 2
- 3
- 4
- 5
//...
float a = 7;
printf("%d", *(unsigned int *)(&a) >> 23);
// Что напечатает?
//...
На экзамене как-то задали такой вопрос. А ну-ка, кто без компилятора ответит?
GonZaleZ,
18 Февраля 2014
-
−101
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
def Find(dir):
def walk(a,b,files):
t1=0
for i in files:
t1+=1
if i[-4:]==".sis" or i[-4:]==".Sis" or i[-4:]==".SIs" or i[-4:]==".SIS" or i[-4:]==".SiS" or i[-4:]==".sIS" or i[-4:]==".siS" or i[-5:]==".sisx" or i[-5:]==".Sisx" or i[-5:]==".SIsx" or i[-5:]==".SISx" or i[-5:]==".SISX" or i[-5:]==".sISX" or i[-5:]==".siSX" or i[-5:]==".sisX" or i[-5:]==".SisX" or i[-5:]==".SIsX" or i[-5:]==".SiSX" :
list1.append(cn(i))
list2.append(cn("%s\%s"%(b,i)))
Когда еще была жива симба, под нее был интерпретатор питона. Этот отрывок - творение некоего китайского товарища под PyS60.
Pythoner,
09 Октября 2013
-
+154
- 1
list($V_id, $V_image, $V_title, $V_text, $V_url, $V_link_to, $V_status) = array('','','','','','','');
множественное присваивание?! не, не слыщал
dead_star,
08 Июля 2013
-
+129
- 1
- 2
- 3
- 4
- 5
Правила пользования метрополитеном
...
9. Всем лицам, находящимся на территории метрополитена, запрещается:
...
9.6. Провозить громоздкий багаж, сумма измерений которого по длине, ширине, высоте, а для рулона - по высоте и двум его диаметрам или осям в основании, превышает 200 см, или длина которого свыше 220 см
TarasB,
10 Июня 2013
-
+132
- 1
public virtual int ReadByte()
Тут в соседнем треде появилась такая тема:
http://msdn.microsoft.com/ru-ru/library/system.io.stream.readbyte.aspx
http://govnokod.ru/12311#comment164854
LispGovno,
20 Декабря 2012