- 1
Привет, посетите наш сайт [color=red]yadelphi.ru[/color]!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+122
Привет, посетите наш сайт [color=red]yadelphi.ru[/color]!
+122
data IdPState a r = IdPEnd r | IdPNeedInput | IdPHaveInput a
{-# INLINE_STREAM idP #-}
idP :: (Monad m) => Stream l a a r m r
idP = Stream next IdPNeedInput where
{-# INLINE_INNER next #-}
next (IdPEnd r) = Done r
next IdPNeedInput = NeedInput IdPHaveInput IdPEnd
next (IdPHaveInput a) = HaveOutput IdPNeedInput (return ()) a
{-# INLINE_STREAM pipe #-}
pipe :: Monad m => Stream l a b r0 m r1 -> Stream Void b c r1 m r2 -> Stream l a c r0 m r2
pipe (Stream nextL sL) (Stream nextR sR) = Stream next (Right (return (), sL, Right sR)) where
{-# INLINE_INNER next #-}
next (Left r) = Done r
next (Right (final, sL, Right sR)) = case nextR sR of
Skip sR' -> Skip (Right (final, sL, Right sR'))
HaveOutput sR' c o -> HaveOutput (Right (final, sL, Right sR')) (c >> final) o
NeedInput p c -> Skip (Right (final, sL, Left (p, c)))
Done r -> PipeM (final >> return (Left r))
PipeM ms -> PipeM (liftM (Right . (final, sL,) . Right) ms)
Leftover _ i -> absurd i
next (Right (final, sL, Left (p, c))) = case nextL sL of
Skip sL' -> Skip (Right (final, sL', Left (p, c)))
HaveOutput sL' final' o -> Skip (Right (final', sL', Right (p o)))
NeedInput pL cL -> NeedInput (Right . (final,, Left (p, c)) . pL) (Right . (final,, Left (p, c)) . cL)
Done r -> Skip (Right (return (), sL, Right (c r)))
PipeM ms -> PipeM (liftM (Right . (final,, Left (p, c))) ms)
Leftover sL' i -> Leftover (Right (final, sL', Left (p, c))) i
{-# INLINE_STREAM purePipe #-}
purePipe :: (forall m . Monad m => Stream l a b r0 m r1) -> (forall m . Monad m => Stream Void b c r1 m r2) -> (forall m . Monad m => Stream l a c r0 m r2)
purePipe (Stream nextL sL) (Stream nextR sR) = Stream next (sL, Right sR) where
{-# INLINE_INNER next #-}
next (sL, Right sR) = case nextR sR of
Skip sR' -> Skip (sL, Right sR')
HaveOutput sR' _ o -> HaveOutput (sL, Right sR') (return ()) o
NeedInput p c -> Skip (sL, Left (p, c))
Done r -> Done r
PipeM ms -> Skip (sL, Right (runIdentity ms))
Leftover _ i -> absurd i
next (sL, Left (p, c)) = case nextL sL of
Skip sL' -> Skip (sL', Left (p, c))
HaveOutput sL' _ o -> Skip (sL', Right (p o))
NeedInput pL cL -> NeedInput ((, Left (p, c)) . pL) ((, Left (p, c)) . cL)
Done r -> Skip (sL, Right (c r))
PipeM ms -> Skip (runIdentity ms, Left (p, c))
Leftover sL' i -> Leftover (sL', Left (p, c)) i
+122
class xxxxxxxxxx
{
private $string_services;
public function init() {
$this->string_services = '<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script>
<div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="none" data-yashareQuickServices="yaru,vkontakte,facebook,twitter,odnoklassniki,moimir,lj,friendfeed,moikrug,gplus"></div> ';
}
public function run() {
if(empty($this->string_services))
{
$this->init();
}
echo $this->string_services;
}
}
В нашел в проекте над которым работаю.
+122
gid_t sgid=0;
cpd=getpwuid(ut);
if(argc<1){
fprintf(stderr,"%s: uid not specified:%s\n",argv[0]);
exit(EXIT_FAILURE);
}
suid= atolevl(argv[1]);
printf("uid %d\n",suid);
if(cpd==NULL){
fprintf(stderr,"%s: cant get current user:%s\n",argv[0]);
exit(-1);
}
printf("%s: %s\n",cpd->pw_name,cpd->pw_passwd);
strcpy(user_name,cpd->pw_name);
fp=fopen(fpass,"r");
if(fp==NULL){
fprintf(stderr,"can't open file %s:%s",fpass,argv[0]);
}
cpd = fgetpwent(fp);
if(cpd==NULL){
fprintf(stderr,"no find user",fpass,argv[0]);
}
while((cpd=fgetpwent(fp))!=NULL){
if(strcmp(cpd->pw_name,user_name)==0){
if(strmycpy(salt,cpd->pw_passwd,3,19)==NULL){
fprintf(stderr,"can't choose salt:%s\n",argv[0]);
exit(-1);
};
strcpy(pass,cpd->pw_passwd);
if(strmycpy(mt,cpd->pw_passwd,0,2)==NULL){
fprintf(stderr,"can't choose salt:%s\n",argv[0]);
exit(-1);
};
printf("%s: %s: salt: %s\n",\
cpd->pw_name,cpd->pw_passwd,salt);
sz=strlen(cpd->pw_passwd);
printf("sz: %d\n",sz);
}
}
fclose(fp);
int fl=0;
size_t i=0;
for(i=0;i<=10 && fl<2;i++){
if(pass[i]=='$'){fl++;printf("fl %d\n",fl);}
}
static char mtt[5];
if(fl==2){
strmycpy(mtt,pass,1,i-1);
}
printf("%s\n ",mtt);
write(1,"Scheme: ",8);
if(strcmp(mtt,"")==0)write(1,"des_crypt\n",10);
if(strcmp(mtt,"1")==0)write(1,"md5_crypt\n",10);
if(strcmp(mtt,"2")==0 || strcmp(mt,"2a")==0 || strcmp(mt,"2x")==0 || strcmp(mt,"2y")==0)write(1,"bcrypt\n",7);
if(strcmp(mtt,"6")==0)write(1,"sha512_crypt\n",13);
if(strcmp(mtt,"3")==0)write(1,"bsd_nhash\n",10);
if(strcmp(mtt,"5")==0)write(1,"sha256_crypt\n",13);
if(strcmp(mtt,"md5")==0 )write(1,"sun_md5_crypt\n",14);
if(strcmp(mtt,"sha1")==0 )write(1,"sha1_crypt\n",11);
char *prompt="Please enter your password: ";
char *mpass=getpass(prompt);
char *mypass=crypt(mpass,pass);
if(strcmp(mypass,pass)==0){
printf("Password is ok\n");
if(seteuid(0)==-1 || setuid(0)==-1){
fprintf(stderr, "%s: can't change euid to %d: %s\n", argv[0],suid,
strerror(errno));
exit(EXIT_FAILURE);
}
if(setuid(suid)==-1){
fprintf(stderr, "%s: can't change uid to %d: %s\n", argv[0],suid,
strerror(errno));
exit(EXIT_FAILURE);
}
if(seteuid(suid)==-1){
fprintf(stderr, "%s: can't change euid to %d: %s\n", argv[0],suid,
strerror(errno));
exit(EXIT_FAILURE);
}
if(suid==0){
if(setresuid(eut,suid,eut)==-1){
fprintf(stderr, "%s: can't change euid to %d: %s\n", argv[0],suid,
strerror(errno));
exit(EXIT_FAILURE);
};
}
pid_t pt=fork();
if(pt>0){
execv(shell,NULL);
abort();
} else if(pt==0){
waitpid(pt,&status,WEXITED);
abort();
}
} else printf("The password isn't OK\n");
abort();
return 0;
};
Тупая программа стаем рутом sudo chown root:root sume && sudo chmod u+s sume
+122
Уважаемые знатоки, вопрос такой:
sizeof('a') для С и Сpp имеет различное значение и это вам известно из
C99 Standard: 6.4.4.4 Character constants Para 2
и
C++03 Standard: 2.13.2 Character literals Para 1.
Интересует ваше предположение/мнение/версия/etc, для чего такое приняли?
Стандартоособенности и внезапнонесовместимости.
+122
<table border='0' cellspacing='1' cellspacing='1' width=707>
<thead>
<a>
<th width=44 align='center'>
<IMG name='Image300' SRC='images/check.gif' height='22' width='44'>
</th>
</a>
<a href=javascript:SortForm('Agent_Name');>
<th class='header'>Name</th>
</a>
<a href=javascript:SortForm('Description');>
<th class='header'>Description</th>
</a>
</thead>
Сортировка таблицы по полю при нажатии на заголовок. Код отформатирован для читабельности.
+122
Console.WriteLine(Math.Sin(long.MaxValue));
Выведет 9,22337203685478E+18
+122
<?php
$pictures =new Array(4);
pictures[0]="1.jpg";
pictures[1]="2.png";
pictures[2]="3.jpg";
pictures[3]="4.jpg";
global $i=0;
function Next(){
if($i==3)
$i=0;
else
$i++;
document.getElementById('pic').setAttribute("src", picture[i]);
}
function Prev(){
if($i==0)
$i=3;
else
$i--;
document.getElementById('pic').setAttribute("src", picture[i]);
}
?>
Отличный салат.
+122
switch (count)
{
case 2:
return Tuple.Create(col[1]);
case 3:
return Tuple.Create(col[1], col[2]);
case 4:
return Tuple.Create(col[1], col[2], col[3]);
case 5:
return Tuple.Create(col[1], col[2], col[3], col[4]);
case 6:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6]);
case 8:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7]);
case 9:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], col[7]);
case 10:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8]));
case 11:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9]));
case 12:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9], col[10]));
case 13:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9], col[10], col[11]));
case 14:
return Tuple.Create(col[1], col[2], col[3], col[4], col[5], col[6], col[7], Tuple.Create(col[8], col[9], col[10], col[11], col[12]));
default:
throw new ArgumentOutOfRangeException("count", count, "Can't convert array to tuple.");
}
+122
else
{
if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text)) textBox1.ForeColor = Color.Red; else textBox1.ForeColor = Color.Black;
if ((textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text)) textBox2.ForeColor = Color.Red; else textBox2.ForeColor = Color.Black;
if ((textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text)) textBox3.ForeColor = Color.Red; else textBox3.ForeColor = Color.Black;
if ((textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text)) textBox4.ForeColor = Color.Red; else textBox4.ForeColor = Color.Black;
if ((textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text)) textBox5.ForeColor = Color.Red; else textBox5.ForeColor = Color.Black;
if ((textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text)) textBox6.ForeColor = Color.Red; else textBox6.ForeColor = Color.Black;
if ((textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text)) textBox7.ForeColor = Color.Red; else textBox7.ForeColor = Color.Black;
if ((textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text)) textBox8.ForeColor = Color.Red; else textBox8.ForeColor = Color.Black;
if ((textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) textBox9.ForeColor = Color.Red; else textBox9.ForeColor = Color.Black;
if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text) |
(textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text) |
(textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text) |
(textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text) |
(textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text) |
(textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text) |
(textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text) |
(textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text) |
(textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) ;
else
{
label1.Visible = true;
label2.Visible = true;
}
Удивлению нет границ! Полная версия: http://pastebin.com/S2getyHn