- 1
- 2
- 3
- 4
- 5
- 6
- 7
</head>
<script type="text/javascript">
$(document).ready(function() {
...
});
</script>
<body>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+132
</head>
<script type="text/javascript">
$(document).ready(function() {
...
});
</script>
<body>
Не до, и не после - между блять!
+132
static volatile int rotatelog=0;
void daemonize();
void *receive_thread(void *ptr);
void *write_thread(void *ptr);
void sighup_hdl(int signal);
FILE *hfl_log;
int main(){
daemonize();
hfl_log=fopen(HM_LOGFILE, "a");
setlinebuf(hfl_log);
signal(SIGHUP,sighup_hdl);
receive_thread(NULL);
return 0;
}
void daemonize(){
int devnullfd = -1;
umask(~0700);
devnullfd = open("/dev/null", 0);
dup2(devnullfd, STDIN_FILENO);
dup2(devnullfd, STDOUT_FILENO);
close(devnullfd);
switch(fork()) {
case -1:
perror("fork");
exit(1);
break;
case 0:
break;
default:
exit(0);
break;
}
}
void *receive_thread(void *ptr){
int udpsock, i;
struct _peventmsg *pmsg;
struct sockaddr_in serv;
socklen_t servlen;
ssize_t len;
time_t tm;
char sign1[SHA_DIGEST_LENGTH], sign2[SHA_DIGEST_LENGTH];
udpsock=socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (udpsock==-1)
return NULL;
i=32*1024*1024;
setsockopt(udpsock, SOL_SOCKET, SO_RCVBUFFORCE, (void*)&i, sizeof(i));
memset(&serv, 0, sizeof(serv));
serv.sin_family = AF_INET;
serv.sin_port = htons(TSPORT);
serv.sin_addr.s_addr = inet_addr(TSIP);
if (bind(udpsock, (struct sockaddr *)&serv, sizeof(struct sockaddr_in))){
close(udpsock);
return NULL;
}
while (1){
if (rotatelog){
rotatelog=0;
//fflush(hfl_log); fclose() should be enough
fclose(hfl_log);
hfl_log=fopen(HM_LOGFILE, "a");
//do we really tail -f that much on this log that we need it line buffered? It requires 1 write per incoming packet
setlinebuf(hfl_log);
}
pmsg=(struct _peventmsg *)malloc(sizeof(struct _peventmsg));
servlen=sizeof(serv);
len=recvfrom(udpsock, &pmsg->msg, sizeof(pmsg->msg), 0, (struct sockaddr *)&serv, &servlen);
if (len!=sizeof(pmsg->msg)){
free(pmsg);
continue;
}
time(&tm);
if (pmsg->msg.tm+20<tm || pmsg->msg.tm-20>tm){
free(pmsg);
continue;
}
memcpy(sign1, pmsg->msg.sign, sizeof(sign1));
memset(pmsg->msg.sign, 0, sizeof(pmsg->msg.sign));
strcpy(pmsg->msg.sign, SECRET);
SHA1((unsigned char *)&pmsg->msg, sizeof(pmsg->msg), (unsigned char *)sign2);
if (memcmp(sign1, sign2, sizeof(sign1))){
free(pmsg);
continue;
}
strcpy(pmsg->ip, inet_ntoa(serv.sin_addr));
fprintf(hfl_log, "%ld %s %lu %u %u %u %u %s\n",
le64toh(pmsg->msg.tm), pmsg->msg.ip, le64toh(pmsg->msg.bytessent), le32toh(pmsg->msg.seconds),
le32toh(pmsg->msg.ttype), le32toh(pmsg->msg.tcpi_total_retrans), le32toh(pmsg->msg.tcpi_snd_mss), pmsg->ip);
free(pmsg);
}
}
Traffic analysis tool: http://vasil.ludost.net/blog/?p=3029
+106
/*FuckingMagic*/
public static T[] GetT<T>(int _RepeatCount, Func<IExpression, T[]> _GetT, IExpression[] _Expressions) {
T[] __outbytes;
T[][] __tmp_bytes;
int __offset = 0, __tmp_sz = 0, __i = 0, __j = 0, __ex_l = _Expressions.Length;
__ex_l = _Expressions.Length;
__tmp_bytes = new T[__ex_l * _RepeatCount][];
for ( __j = 0; __j < _RepeatCount; __j++ )
for ( __i = 0; __i < __ex_l; __i++ )
__tmp_bytes[__j * __ex_l + __i] = _GetT(_Expressions[__i]);
__j = __tmp_bytes.Length;
for ( __i = 0; __i < __j; __tmp_sz += __tmp_bytes[__i].Length, __i++ ) ;
__outbytes = new T[__tmp_sz];
for ( __i = 0; __i < __j; __i++ ) {
__tmp_sz = __tmp_bytes[__i].Length;
Array.Copy(__tmp_bytes[__i], 0, __outbytes, __offset, __tmp_sz);
__tmp_bytes[__i] = null;
__offset += __tmp_sz;
}
return __outbytes;
}
С тех пор я всегда пишу код трезвым.
+125
$ find . -type f -name '*.asp' -exec grep -nHi 'select \*' {} \; | wc -l
2160
teh drama :(
+71
private static final int IDX_OBJECT = 0;
private static final String PARTY_ACCOUNT_BALANCE_QUERIES = "Select party.id from Party party WHERE party.TaxID='615100175';Select account.id from PaymentAccount account, Party party WHERE party.TaxID='615100175';Select balance.id from PaymentBalance balance WHERE balance.BalanceType='10000';";
private static final int queryAmount = 3;
public void createPaymentAccountUpdate() {
String[] QUERY = new String[queryAmount];
int startIndex = 0, endIndex=0;
IRecordset [] rs=null;
for (int i = 0; i < queryAmount; i++) {
endIndex = PARTY_ACCOUNT_BALANCE_QUERIES.indexOf(';', startIndex);
QUERY[i] = PARTY_ACCOUNT_BALANCE_QUERIES.substring(startIndex, endIndex);
startIndex = endIndex + 1;
}
for (int i = 0; i < queryAmount; i++) {
rs[i] = s_mgr.newQuery().execute(QUERY[i].toString());
}
if (rs[0].moveNext()) {
IParty party = (IParty)rs[0].valueFromIndex(IDX_OBJECT);
if (rs[1].moveNext()) {
IPaymentAccount pa = (IPaymentAccount) rs[1].valueFromIndex(IDX_OBJECT);
pa.setParty(party);
}
if (rs[2].moveNext()) {
IPaymentBalance pb = (IPaymentBalance) rs[2].valueFromIndex(IDX_OBJECT);
pa.setBalance(pb);
}
pa.setComment("Test account update created");
pa.Save();
}
}
Лучше уж никаких тестов, чем такие
+9
y=fopen(lex,"w+");
fclose(y);
FILE *r=fopen(result,"w+");
fclose(r);
FILE *k=fopen("pryklad.obj","w+");
fclose(k);
+121
#Creates an array with the frequencies from C2 to C5, 37 notes in all
for j from 1 to 37
if j = 1
notes [j] = 65.41 # лёгкие пути не нужны
endif
if j = 2
notes [j] = 69.30
endif
# ...дальше понятно...
endfor
# <...>
#Determining whether or not the scale contains C
#This determines how many notes of the 37 possible must be included.
noCList [1] = 3 # опа, а вот тут уже научились числовые индексы использовать
noCList [2] = 5
noCList [3] = 7
noCList [4] = 10
noCList [5] = 12
noC = 0
for n from 1 to 5
if 'starter' = noCList['n']
noC = 1
endif
endfor
#If there is a C...
if noC = 0
#The for loop mathematically selects the scale notes to use
for m from 1 to 22
if 'm' = 1
noteind = 'starter'
endif
if 'm' = 2
noteind = 'starter' + 2
if 'noteind' > 37
noteind = 'noteind' - 36
endif
endif
# ...ага-ага...
scalenotes ['m'] = notes['noteind']
endfor
#If there is not a C...
else
for m from 1 to 21
if 'm' = 1
noteind = 'starter'
endif
if 'm' = 2
noteind = 'starter' + 2
if 'noteind' > 37
noteind = 'noteind' - 36
endif
endif
# ...так точно...
scalenotes ['m'] = notes['noteind']
endfor
endif
# <...>
#Add new pitch information
#For each point, we move the freq to the closest scale note
for q from 1 to 'numPoints'
#The original freq of pitch
currentfreq = pitches['q']
#A starting threhold for difference between original and a musical note
diff = 50
#If there is C in the scale, making 22 possible notes to tune to...
if 'noC' = 0
#For loop finds the lowest difference between original pitch and a musical note
for c from 1 to 22
diff2 = abs('currentfreq' - scalenotes['c'])
if 'diff2' < 'diff'
diff = 'diff2'
noteindex = 'c'
endif
endfor
#Otherwise if there is not a C...
else
for c from 1 to 21
diff2 = abs('currentfreq' - scalenotes['c'])
if 'diff2' < 'diff'
diff = 'diff2'
noteindex = 'c'
endif
endfor
endif
#Add point at the original time with the new pitch
Add point... times['q'] scalenotes['noteindex']
endfor
http://schyzm.wordpress.com/2012/12/05/fun-with-praat-a-script-for-auto-tune/
Скрипт питч-коррекции для речевого анализатора Praat на встроенном языке сценариев. Не знаю, это афтар так жжот или язык располагает к черезжопию, но что-то тут воняет однозначно.
+136
http://f.cl.ly/items/1B362r0E3T0z3E3v3A1f/Screen%20Shot%202013-01-10%20at%2011.01.45.png
Это надо видеть.
+69
//А теперь я научу вас как правильно определять тип картинки
$type = '';
# JPEG:
$src = @imagecreatefromjpeg("./js/ajax_drag_drop_upload/php/files/".$f);
if ($src !== false)
{
$type = 'jpg';
}
else {
# GIF:
$src = @imagecreatefromgif("./js/ajax_drag_drop_upload/php/files/".$f);
if ($src !== false)
{
$type = 'gif';
}
else {
# PNG:
$src = @imagecreatefrompng("./js/ajax_drag_drop_upload/php/files/".$f);
if ($src !== false)
{
$type = 'png';
}
}
// А что делать с BMP? Та ну нафиг, BMP - это миф...
}
// Вот и все. Теперь вы знаете с каким типом картинки работаете
// Ну а здесь уже можете писать ваш говнокод
Очень эпичный code snippet. Посмотрите как автор ловко владеет возможностями языка PHP. В закладки!
+73
if (jsonValues.toString().contains("acctContext") == true) {
try {
objectRelMethod = impl.provisionDevice(
jsonValues.getString("acctContext"),
jsonValues.getString("persoIdentityRequest"));
}catch(JSONException e){
objectRelMethod = impl.provisionDevice(null, null);
}
}
и туда же... и это называется гордым словом "мидл"...