- 1
- 2
- 3
- 4
- 5
int main()
{
...
return rand();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+97.4
int main()
{
...
return rand();
}
Иногда даже вылетают ошибки!
+128.5
program kot;
var r,i,j, z : integer ;
famnom: array[1..11,1..26] of char;
Label lb1, lb2;
begin
Assign(input, 'c:\pascal\kot.txt');
Reset(input);
Assign(output, 'c:\pascal\tok.txt');
Rewrite(output);
for j:=1 to 10 do
for i:=1 to 26 do (*каждому символу присваивается свой номер в массиве*)
begin
read(input,famnom[j,i]);
write(famnom[j,i]); (*исходные данные копируются в файл*)
end;
writeln('');
writeln('');
close(input);
Assign(input, 'c:\pascal\kot.txt');
Reset(input);
begin
lb1 : for j:=1 to 10 do
begin
i:= 16;
while famnom[j,i]=famnom[j+1,i] do
i:=i+1; (*блабла*)
if famnom[j,i]<famnom[j+1,i] then
begin
for i := 1 to 26 do
begin
famnom[11,i]:=famnom[j,i]; (*сравниваются символы короч*)
famnom[j,i]:=famnom[j+1,i];
famnom[j+1,i]:=famnom[11,i];
end;
goto lb1;
end;
end;
end;
for j:=1 to 10 do
for i:= 1 to 26 do
begin
write(famnom[j,i]);
end;
close(input);
close(output);
end.
Ужас какойто
+140
char *bukva="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
char *cifra="1234567890";
//тут получаем строку
while((ch = getc(fp)) != EOF) {
putc(ch,stdout);
if(ch == ' ') {probel++; continue;}
for (j = 0; j < (strlen(cifra)); j++) {
if(ch == cifra[j])
countcifra++;
}
for (j = 0;j < (strlen(bukva)); j++) {
if(ch == bukva[j])
countbukva++;
}
}
Из лабораторки однокурсника. Подсчет количества букв и цифр в строке
+185
define('KEY', md5('Obama'));
if($_GET['key'] != KEY) {
...
}
таки обамосекьюрность))
встретилось в одном большом проекте, который успешно работает и процветает по сей день
+138.2
if(true)
{
//Код
}
else
{
//Закомментированно, но компилируется. ^_^
};
Способ комментирования... O_o
+84
char* c=a;
char* d=b;
while(*(c++)=*(d++));
Кажется страус труп предложил. Копирование из буфера PChar b в буфер PChar a.
+153
<?
ob_start();
session_start();
include("includes/applicationTop.php");
?>
<?
if($_SESSION["CONTACT_ID"]=="" || $_SESSION["CONTACT_ID"]==0)
{
$contact_id=$_GET['contact_id'];
}
else
{
$contact_id = $_SESSION["CONTACT_ID"];
}
if($_SESSION["ORDER_ID"]=="" || $_SESSION["ORDER_ID"]==0)
{
$order_id=$_GET['order_id'];
}
else
{
$order_id = $_SESSION["ORDER_ID"];
}
$selBillingInfo = "SELECT * FROM `contact` WHERE `contact_id`='".$contact_id."'";
$resBillingInfo = $db->select_data($selBillingInfo);
$selOrderInfo = "SELECT * FROM `order` WHERE `order_id`='".$order_id."'";
$resOrderInfo = $db->select_data($selOrderInfo);
?>
<? $exesql=mysql_query("select * from admin_updation where id = 1");
$rs=mysql_fetch_object($exesql); $to_mail=$rs->paypal_id;?>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="30"><img src="images/spacer.gif" width="30" height="1" /></td>
<td><form class="formclass" method="post" action="https://www.paypal.com/cgi-bin/webscr" id="myform" name="theForm" ><!--<form class="formclass" method="post" action="https://www.paypal.com/cgi-bin/webscr" id="myform" name="theForm" >-->
<input name="validate" value="1" type="hidden">
<input type="hidden" name="order_id" value="<?=$order_id?>" />
<?
$paypal[site_url]="http://говносайт";
$paypal[success_url]="/paymentReceipt.php?success=paypal&pt=paypal&contact_id=$contact_id&order_id=$order_id";
$paypal[cancel_url]="/paymentReceipt.php?success=failed&pt=paypal&contact_id=$contact_id&order_id=$order_id";
$paypal[notify_url]="/ipn/ipn.php";
$paypal[return_method]="2"; //1=GET 2=POST
$paypal[currency_code]="USD"; //[USD,GBP,JPY,CAD,EUR]
$paypal[lc]="US";
$paypal[url]="https://www.sandbox.paypal.com/cgi-bin/webscr"; // For Test
$paypal[post_method]="fso"; //fso=fsockopen(); curl=curl command line libCurl=php compiled with libCurl support
$paypal[curl_location]="/usr/local/bin/curl";
$paypal[bn]="toolkit-php";
$paypal[cmd]="_xclick";
$paypal[display_comment]="0"; //0=yes 1=no
$paypal[comment_header]="Comments";
$paypal[continue_button_text]="Continue >>";
$paypal[background_color]="1"; //""=white 1=black
$paypal[display_shipping_address]="1"; //""=yes 1=no
$paypal[display_comment]="1"; //""=yes 1=no
?>
<!--<input type="hidden" name="business" value="[email protected]">--><? // For Live ?>
<input type="hidden" name="business" value="<?=$to_mail?>"><? // For Test ?>
<!--<input type="hidden" name="business" value="[email protected]">--><? // For Test ?>
<input type="hidden" name="item_name" value="Говнобрэнд">
<input type="hidden" name="cmd" value="<?=$paypal[cmd]?>">
<input type="hidden" name="redirect_cmd" value="<?=$paypal[cmd]?>">
<input type="hidden" name="image_url" value="">
<input type="hidden" name="return" value="<? echo "$paypal[site_url]$paypal[success_url]"; ?>">
<input type="hidden" name="cancel_return" value="<? echo "$paypal[site_url]$paypal[cancel_url]"; ?>">
<input type="hidden" name="notify_url" value="<? echo "$paypal[site_url]$paypal[notify_url]"; ?>">
<input type="hidden" name="rm" value="<?=$paypal[return_method]?>">
<input type="hidden" name="currency_code" value="<?=$paypal[currency_code]?>">
<input type="hidden" name="lc" value="<?=$paypal[lc]?>"><input type="hidden" name="bn" value="<?=$paypal[bn]?>">
<input type="hidden" name="cbt" value="<?=$paypal[continue_button_text]?>"><input type="hidden" name="no_shipping" value="<?=$paypal[display_shipping_address]?>">
<input type="hidden" name="no_note" value="<?=$paypal[display_comment]?>">
<input type="hidden" name="order_id" value="<?=$order_id?>"><input type="hidden" name="amount" value="<?=$resOrderInfo[0]['amount']?>">
<input type="hidden" name="first_name" value="<?=$resBillingInfo[0]['first_name']?>"> <input type="hidden" name="last_name" value="<?=$resBillingInfo[0]['last_name']?>">
<input type="hidden" name="company" value="<?=$resBillingInfo[0]['company']?>"><input type="hidden" name="address" value="<?=$resBillingInfo[0]['address']?>">
<input type="hidden" name="city" value="<?=$resBillingInfo[0]['city']?>"><input type="hidden" name="state" value="<?=$resBillingInfo[0]['state']?>">
<input type="hidden" name="zip" value="<?=$resBillingInfo[0]['zip']?>">
<input type="hidden" name="country" value="<?=$resBillingInfo[0]['country']?>">
<input type="hidden" name="phone" value="<?=$resBillingInfo[0]['phone']?>"> <input type="hidden" name="email " value="<?=$resBillingInfo[0]['email']?>"> <input type="hidden" name="a3" value="<?=$resOrderInfo[0]['amount']?>">
<input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="no_note" value="1">
<input type="hidden" name="src" value="1"><input type="hidden" name="sra" value="1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="text_body"> </td>
</tr>
<tr>
<td align="left"></td>
</tr>
</table>
</form></td>
<td width="15"><img src="images/spacer.gif" width="15" height="1" /></td>
</tr>
</table>
<script language="JavaScript">
objfrm = document.getElementById("myform");
objfrm.submit();
</script>
А вот занятный способ переброса посетителя на paypal.
С помощью невидимой формы, который сама засабмитится (может быть).
Источник тот же, что у #1244-#1245, #1248-#1250
+46.7
$t = new Table('foo');
$t->th('Header 1');
$t->th('Header 2');
$t->th('Header 3');
$t->endRow();
for($i = 0; $i<10; $i++) {
$t->td('Cell 1');
$t->td('Cell <2>', '', true);
$t->td('Cell 3');
$t->endRow();
}
$t->end();
На выходе получаем html таблицы...
Вот так крутые пацаны понимают термин OOP,
http://habrahabr.ru/sandbox/3112/ человек хочет за изобретение инвайт, ссылка по видимому умрет, так что инвайт дарите быстрее, если шедевр вас тронул :)
+60.3
function fromunicode($string,$lang){
if ($lang=="fr"):
return utf8_decode($string);
elseif($lang=="rus"):
$tempchar1=chr(208);
$string=ereg_replace( "Рђ" , "А" , $string);
$tempchar2=chr(145);
$tempchar=$tempchar1.$tempchar2;
$string=ereg_replace( $tempchar , "Б" , $string);
$tempchar2=chr( 146);
$tempchar=$tempchar1.$tempchar2;
$string=ereg_replace( $tempchar, "В" , $string);
$tempchar2=chr( 147);
$tempchar=$tempchar1.$tempchar2;
$string=ereg_replace( $tempchar ,"Г" , $string);
$tempchar2=chr( 148);
$tempchar=$tempchar1.$tempchar2;
$string=ereg_replace( $tempchar, "Д" , $string);
$string=ereg_replace( "Р•" , "Е" , $string);
$string=ereg_replace( "РЃ" ,"Ё" , $string);
$string=ereg_replace( "Р–" , "Ж" , $string);
$string=ereg_replace( "Р—" , "З" , $string);
$string=ereg_replace( "Р?" , "И" , $string);
$string=ereg_replace( "Р™" , "Й" , $string);
$string=ereg_replace( "Рљ" , "К" , $string);
$string=ereg_replace( "Р›" , "Л" , $string);
$string=ereg_replace( "Рњ" , "М" , $string);
$string=ereg_replace( "Рќ" , "Н" , $string);
$string=ereg_replace( "Рћ" , "О" , $string);
$string=ereg_replace( "Рџ" , "П" , $string);
//$string=ereg_replace( "Р" , "Р " , $string);
//$string=ereg_replace( "С" , "РЎ" , $string);
$string=ereg_replace( "Рў" , "Т" , $string);
$string=ereg_replace( "РЈ" , "У" , $string);
$string=ereg_replace( "Р¤" , "Ф" , $string);
$string=ereg_replace("РҐ" , "Х" , $string);
$string=ereg_replace( "Р¦" , "Ц" , $string);
$string=ereg_replace( "Р§" , "Ч" , $string);
$string=ereg_replace( "РЁ" , "Ш" , $string);
$string=ereg_replace( "Р©" , "Щ" , $string);
$string=ereg_replace( "Р¬" , "Ь" , $string);
$tempchar2=chr( 170);
$tempchar=$tempchar1.$tempchar2;
$string=ereg_replace( $tempchar,"Ъ" , $string);
//echo "tempmygk=$tempchar";
$tempchar2=chr( 171);
$tempchar=$tempchar1.$tempchar2;
// $string=ereg_replace( $tempchar3,$tempchar, $string);
$string=ereg_replace( $tempchar,"Ы" , $string);
//echo "tempy=$tempchar";
$string=ereg_replace("Р" , "Э" , $string);
$string=ereg_replace( "Р®" , "Ю" , $string);
$string=ereg_replace( "РЇ" , "Я" , $string);
// small
$string=ereg_replace( "Р°" ,"а" , $string);
$string=ereg_replace( "Р±" ,"б" , $string);
$string=ereg_replace( "РІ" ,"в" , $string);
$string=ereg_replace( "Рі" ,"г" , $string);
$string=ereg_replace( "Рґ" , "д" , $string);
$string=ereg_replace( "Рµ" ,"е" , $string);
$string=ereg_replace( "Рµ" ,"ё" , $string);
// $string=ereg_replace( "С'" , "ё" , $string);
$string=ereg_replace( "Р¶" , "ж" , $string);
$string=ereg_replace( "Р·" , "з" , $string);
$string=ereg_replace( "Рё" ,"и" , $string);
$string=ereg_replace( "Р№" ,"й" , $string);
$string=ereg_replace("Рє" , "к" , $string);
$string=ereg_replace( "Р»" , "л" , $string);
$string=ereg_replace( "Рј" , "м" , $string);
$string=ereg_replace( "РЅ" , "н" , $string);
$string=ereg_replace( "Рѕ" , "о" , $string);
$string=ereg_replace("Рї" , "п" , $string);
$string=ereg_replace("СЂ" , "р" , $string);
$string=ereg_replace("СЃ" , "с" , $string);
$string=ereg_replace( "С‚" , "т" , $string);
$string=ereg_replace( "Сѓ" , "у" , $string);
$string=ereg_replace( "С„" , "ф" , $string);
$string=ereg_replace( "С…" , "х" , $string);
$string=ereg_replace( "С†" , "ц" , $string);
$string=ereg_replace( "С‡" , "ч" , $string);
$string=ereg_replace( "С?" , "ш" , $string);
$string=ereg_replace( "С‰" , "щ" , $string);
$string=ereg_replace( "СЊ" ,"ь" , $string);
$string=ereg_replace( "С‹" , "ы" , $string);
$string=ereg_replace( "СЉ" , "ъ" , $string);
$string=ereg_replace( "СЌ" , "э" , $string);
$string=ereg_replace( "СЋ" , "ю" , $string);
$string=ereg_replace("СЏ" , "я" , $string);
$string=ereg_replace("Р " , "Р" , $string);
−354.1
def getCodeType(ext):
codeType = ""
extensions = [
".py","python",
".cpp","cpp",
".sh","bash",
".pl","perl",
".php","php",
".LUA","lua",
".js", "javascript",
".java","java",
".html","html4strict",
".cs","csharp"
]
x = 0
while x < 5:
if extensions[x] == ext:
codeType = extensions[x + 1]
break
else:
x += 2
return codeType
def getCodeType(ext):
extensions = { ... }
try: return extensions[ext]
except KeyError: return ''