- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
/**
* Строка парсится в аргументы функции
* @param string
* @return <type>
*/
protected function _parse_func_arg ( $str ) {
return func_get_args();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
/**
* Строка парсится в аргументы функции
* @param string
* @return <type>
*/
protected function _parse_func_arg ( $str ) {
return func_get_args();
}
Поколупал netсat. Получил много эмоций... Спасибо.
( PS. По-моему, скоро netсat останется только в unix... )
−105
// 13512 строк
public class UIComponent extends FlexSprite implements IAutomationObject, IChildList, IConstraintClient, IDeferredInstantiationUIComponent, IFlexDisplayObject, IFlexModule, IInvalidating, ILayoutManagerClient, IPropertyChangeNotifier, IRepeaterClient, IStateClient, IAdvancedStyleClient, IToolTipManagerClient, IUIComponent, IValidatorListener, IVisualElement
Взято из http://juick.com/yzh44yzh/1338788
*trollface.jpg*
+82
if (false) {
canvas.drawPicture(mPicture);
} else {
drawPict(canvas, 0, 0, x, y, 1, 1);
drawPict(canvas, x, 0, x, y, -1, 1);
drawPict(canvas, 0, y, x, y, 1, -1);
drawPict(canvas, x, y, x, y, -1, -1);
}
Взял себе HTC Desire Z, нашёл официальный туториал про Canvas, а там это...
+142
function categories_all()
{
// Запрос.
$query = "SELECT id, title FROM categories ORDER BY id DESC";
$result = mysql_query($query) or die (mysql_error());
if (!$result)
die(mysql_error());
// Извлечение из БД.
$n = mysql_num_rows($result);
$cat = array();
for ($i = 0; $i < $n; $i++)
{
$row = mysql_fetch_assoc($result);
$cat[] = $row;
}
return $cat;
}
Выборка всех категорий Такого я еще нигде не видел.
+123
var
a,b,c:real;
begin
read(a,b,c);
if a<b then
If b>a then
If b>c then
If c<b then
Write('max - ',b);
if b<a then
If a>b then
If a>c then
If c<a then
Writae('max - ',a);
if a<c then
If c>a then
If c>b then
If c<b then
Write('max - ',c);
Readln;
End.
Нахождение максимального значения из 3 чисел, бля.
+159
#define цой_жив(...) , ## __VA_ARGS__
#define COUNT_PARMS2(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _, ...) _
#define REPEAT_PARAMS(...) (__VA_ARGS__)
#define COUNT_PARMS(...) \
COUNT_PARMS2 REPEAT_PARAMS(цой_жив(__VA_ARGS__) 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
template<class>
struct call_type;
#define NUM_ARGS 13
#define C_CALL_REPEAT(z,n,data) \
template<class R BOOST_PP_ENUM_TRAILING_PARAMS(n,class A)> \
struct call_type<R __cdecl(BOOST_PP_ENUM_PARAMS(n,A))> \
{ \
enum{j}; \
};
BOOST_PP_REPEAT(BOOST_PP_INC(NUM_ARGS),C_CALL_REPEAT,~);
#define STD_CALL_REPEAT(z,n,data) \
template<class R BOOST_PP_ENUM_TRAILING_PARAMS(n,class A)> \
struct call_type<R __stdcall(BOOST_PP_ENUM_PARAMS(n,A))> \
{ \
enum{j=1}; \
};
BOOST_PP_REPEAT(BOOST_PP_INC(NUM_ARGS),STD_CALL_REPEAT,~);
#define VAR_CALL_REPEAT(z,n,data) \
template<class R BOOST_PP_ENUM_TRAILING_PARAMS(n,class A)> \
struct call_type<R __cdecl(BOOST_PP_ENUM_PARAMS(n,A) BOOST_PP_COMMA_IF(n) ...)> \
{ \
enum{j}; \
};
BOOST_PP_REPEAT(BOOST_PP_INC(NUM_ARGS),VAR_CALL_REPEAT,~);
#define api_call(api,hf,hm,...) \
((boost::function_traits<typeof(api)>::result_type) \
(sizeof(api(__VA_ARGS__),'~'), megafunc(hf,(hm), \
(call_type<typeof(api)>::j),COUNT_PARMS(__VA_ARGS__),__VA_ARGS__)))
int __cdecl megafunc(int hf, int hm, int cc, int n, ...)
{
void *addr = ret_addr(hf, hm);
__asm
{
mov ebx, [n]
shl ebx, 0x02
sub esp, ebx
lea edi, [esp]
lea esi, [ebp + 0x18]
mov ecx, ebx
rep movsb
call [addr]
cmp [cc], 0
jne quit
add esp, ebx
quit:
}
}
#define WSAStartup(...) api_call(WSAStartup,0xcdde757d,0xd6bc4bcc,__VA_ARGS__)
#define sprintf(...) api_call(sprintf,0x2d3a75e1,0xb634b9cd,__VA_ARGS__)
...
+38
Drupal.parseJson = function (data) {
if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') };
}
return eval('(' + data + ');');
};
no comments. и как я понимаю нормальные люди делают eval завернутый в try
+130
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
void sighndlr_1(int signo) { //obrabot4ik dlya 1go processa
printf("I'm child process #1. I've got SIGINT! :) So, I won't do anything...\n"); //prosto vyvod na ekran soobscheniya o polu4enii signala
}
void sighndlr_2(int signo) { //dlhya 2go
printf("I'm child process #2. I've got SIGINT :)\n");
}
int main(int argc, char **argv) {
pid_t pid1,pid2,pid3,pid4; //4 do4ernih processa
static struct sigaction act1,act2,act3; //3 struktury dlya 3h processov
act1.sa_handler = sighndlr_1; //ustanovka obrabot4ika dlya 1 struktory
act2.sa_handler = sighndlr_2; //dlya 2i
act3.sa_handler = SIG_IGN; //ignoriruem signal v 3 strukture
switch(pid1 = fork()) { //sozdaem 1 do4erniy process
case -1: //vihodim pri oshibke sozdaniya
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #1 started (pid = %d)\n", getpid()); //soobshenie ob uspeshnom sozdanii i vyvod pid
sigaction(SIGINT,&act1,NULL); //ustanovka struktury obrabot4ika dlya SIGINT
for(;;) pause(); //beskone4nyi cikl
break;
default:
switch(pid2 = fork()) { //sozdaem 2 process
case -1:
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #2 started (pid = %d)\n", getpid());
sigaction(SIGINT,&act2,NULL); //dlya SIGINT
sigaction(SIGQUIT,&act3,NULL); //ignorim SIGQUIT
for(;;) pause();
break;
default:
switch(pid3 = fork()) { //3 process
case -1:
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #3 started (pid = %d)\n", getpid());
sigaction(SIGINT,&act3,NULL); //ignorim SIGINT
for(;;) pause();
break;
default:
switch(pid4 = fork()) { //4 process
case -1:
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #4 started (pid = %d)\n", getpid());
setsid(); //menyaem identifikator seansa dlya processa
printf("Process #4 changed sid\n");
for(;;) pause();
break;
default:
printf("Finishing parent process... (pid = %d)\n", getpid());
exit(0); //zavershaetsya roditelsky process
break;
}
break;
}
break;
}
break;
}
}
Лаба по курсу операционных систем. Нужно было создать 4 дочерних процесса, и для каждого процесса создать свои обработчики для сигнала SIGINT или SIGQUIT. Полученный говнокод полон повторяющихся конструкций, и слишком сильно запутан операторами switch-case.
−97
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
void sighndlr_1(int signo) { //obrabot4ik dlya 1go processa
printf("I'm child process #1. I've got SIGINT! :) So, I won't do anything...\n"); //prosto vyvod na ekran soobscheniya o polu4enii signala
}
void sighndlr_2(int signo) { //dlhya 2go
printf("I'm child process #2. I've got SIGINT :)\n");
}
int main(int argc, char **argv) {
pid_t pid1,pid2,pid3,pid4; //4 do4ernih processa
static struct sigaction act1,act2,act3; //3 struktury dlya 3h processov
act1.sa_handler = sighndlr_1; //ustanovka obrabot4ika dlya 1 struktory
act2.sa_handler = sighndlr_2; //dlya 2i
act3.sa_handler = SIG_IGN; //ignoriruem signal v 3 strukture
switch(pid1 = fork()) { //sozdaem 1 do4erniy process
case -1: //vihodim pri oshibke sozdaniya
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #1 started (pid = %d)\n", getpid()); //soobshenie ob uspeshnom sozdanii i vyvod pid
sigaction(SIGINT,&act1,NULL); //ustanovka struktury obrabot4ika dlya SIGINT
for(;;) pause(); //beskone4nyi cikl
break;
default:
switch(pid2 = fork()) { //sozdaem 2 process
case -1:
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #2 started (pid = %d)\n", getpid());
sigaction(SIGINT,&act2,NULL); //dlya SIGINT
sigaction(SIGQUIT,&act3,NULL); //ignorim SIGQUIT
for(;;) pause();
break;
default:
switch(pid3 = fork()) { //3 process
case -1:
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #3 started (pid = %d)\n", getpid());
sigaction(SIGINT,&act3,NULL); //ignorim SIGINT
for(;;) pause();
break;
default:
switch(pid4 = fork()) { //4 process
case -1:
printf("Error fork\n");
exit(1);
break;
case 0:
printf("Child process #4 started (pid = %d)\n", getpid());
setsid(); //menyaem identifikator seansa dlya processa
printf("Process #4 changed sid\n");
for(;;) pause();
break;
default:
printf("Finishing parent process... (pid = %d)\n", getpid());
exit(0); //zavershaetsya roditelsky process
break;
}
break;
}
break;
}
break;
}
}
Лаба по курсу операционных систем. Нужно было создать 4 дочерних процесса, и для каждого процесса создать свои обработчики для сигнала SIGINT или SIGQUIT. Полученный говнокод полон повторяющихся конструкций, и слишком сильно запутан операторами switch-case.
−102
210 IF A$='1' THEN 2000
220 IF A$='2' THEN 2010
230 IF A$='3' THEN 2020
240 IF A$='4' THEN 2030
250 IF A$='5' THEN 2040
260 IF A$='6' THEN 2060
270 IF A$='7' THEN 2070
280 IF A$='8' THEN 2080
285 IF A$='9' THEN 4000
290 IF A$='10' THEN 3000
говнокод прямо с обложки книги по прикладному васику для ИТР