- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
WORD StrLen(PChar s)
{
ASSERT(s!=NULL);
int i;
for (i=0; ( (*(s+i)!=0) && (i<=WORDMAX) ); i++) {};
ASSERT(i<=WORDMAX);
return (WORD)i;
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
WORD StrLen(PChar s)
{
ASSERT(s!=NULL);
int i;
for (i=0; ( (*(s+i)!=0) && (i<=WORDMAX) ); i++) {};
ASSERT(i<=WORDMAX);
return (WORD)i;
};
По заявкам из http://govnokod.ru/11318
+62
function find( &$db, $id) {
$statement = Contact::findStatement() . " WHERE id = $id";
$dbResult = ActiveRecord::abstractFind( $db, $statement);
foreach ($dbResult as $dbRow) {
return Contact::load( $db, $dbRow);
}
return null;
}
−155
override public function execute():void
{
var maintainProductAttributePresenter:ITableBasedPresentrer = this.appPresenter.maintainProductAttributePresenter;
var maintainProductAttributeView:View = maintainProductAttributePresenter.view;
this.appView.showModuleView(maintainProductAttributeView);
this.appView.showModuleHeader(maintainProductAttributePresenter.getModuleTitle());
maintainProductAttributePresenter.updateData();
}
Сижу, копипазжу... Специально не стала выбиваться из стандарта... Может хоть на секунду мысль о том что мы занимаемся маразмом кому нибудь в голову придет?
−93
# -*- coding: utf-8 -*-
from django.db import models
# Create your models here.
class SheduleItem(models.Model):
WIKDI = (
('monday', 'Понедельник'),
('tuesday', 'Вторник'),
('wednesday', 'Среда'),
('thursday', 'Четверг'),
('friday', 'Пятница'),
('saturday', 'Суббота'),
('sunday', 'Воскресенье'),
)
TAIM = (
('08:00', '08:00'),
('09:00', '09:00'),
('10:00', '10:00'),
('11:00', '11:00'),
('12:00', '12:00'),
('13:00', '13:00'),
('14:00', '14:00'),
('15:00', '15:00'),
('16:00', '16:00'),
('17:00', '17:00'),
('18:00', '18:00'),
('19:00', '19:00'),
('20:00', '20:00'),
('21:00', '21:00'),
)
weekday = models.CharField(max_length=20, choices=WIKDI)
time = models.CharField(max_length=6, choices=TAIM)
action = models.CharField(max_length=30)
trainer = models.ForeignKey('trainers.StrongTrainer')
def __unicode__(self):
return self.action
Django-модель для таблицы расписания занятий. Выдавлено в 2 часа ночи под Сержа Танкяна.
+50
<?php
require('url_to_absolute.php');
ini_set('display_errors','On');
error_reporting('E_ALL');
$ext=array(
'pictures'=>array('bmp','jpg','jpeg','pgm','rgb','tga','png','gif','ico'),
'docs'=>array('rtf','doc','docx','pdf','txt'),
'html'=>array('shtml','html','xml','css','htm','xhtml'),
'audio'=>array('mp3','mp4','mpeg','flv','3gp','webm'),
'arch'=>array('zip','rar','gz','bz2','tar','7zip','ar','tar\.gz','tar\.bz2','xz'),
'pack'=>array('deb','rpm','jar'),
'scripts'=>array('sh','pl','py','php','js')
);
$murl="";
$sext="";
$routh='|((?<=[" ])[^" ]+/[a-z0-9-_%.]+\.';
foreach($ext as $sk=>$sval){
foreach($sval as $exts){
$routh.='(?!'.$exts.'")';
}
}
$routh.='[a-z0-9]{1,5}(?=[" ]))|i';
echo $routh."<br\ >";
if(isset($_GET['url'])){
$url=$_GET['url'];echo $url."<br>";
preg_match('|(ftp)?(http)?(?:s)?://[a-z0-9-]+\.[a-z]+(\.[a-z0-9-_&+?=%]+)*(?::[0-9]+)?|i',$url,$ures);
if(!empty($ures[0])){echo $ures[0];$murl=$ures[0];echo "<br>murl ".$murl."<br> ";}
$html=file_get_contents($url);
foreach($ext as $key=>$val){
echo "<h2>$key</h2><br\>";
foreach($val as $mext){
echo "$mext<br>";
preg_match_all('|((/[.a-z0-9_-]*)*/[a-z0-9-_.%]+\.'.$mext.'(?![a-z])(?!/))|i',$html,$result);
if(!empty($result)){
if(!empty($result[0])){
$result[0]=array_unique($result[0]);
foreach($result[0] as $vres){
$aurl=url_to_absolute($url,$vres);
echo("<a href=\"$aurl\">".$aurl."</a> ");}
}
}
preg_match_all('|((http(?:s)?://)[a-z0-9-]+\.[a-z]+(?:\.[a-z0-9-_&+?=%]+)*(?::[0-9]+)?(?:/[a-z0-9_-.]*)/[.a-z0-9-_%]+\.'.$mext.'(?![a-z])(?!/))|i',$html,$result);
if(!empty($result)){
if(!empty($result[0])){
$result[0]=array_unique($result[0]);
foreach($result[0] as $vres){
$aurl=url_to_absolute($url,$vres);
echo("<a href=\"$aurl\">".$aurl."</a> ");}
}
}
preg_match_all('|((?<=[" ])[^" ]+\.'.$mext.'(?=[" ]))|i',$html,$result);
if(!empty($result)){
if(!empty($result[0])){
$result[0]=array_unique($result[0]);
foreach($result[0] as $vres){
$aurl=url_to_absolute($url,$vres);
echo("<a href=\"$aurl\">".$aurl."</a> ");}
}
}
}
}
preg_match_all($routh,$html,$result);
if(!empty($result)){
if(!empty($result[0])){
$result[0]=array_unique($result[0]);
echo "<br><h2>Other documents</h2><br>";
foreach($result[0] as $vres){
$aurl=url_to_absolute($url,$vres);
echo("<a href=\"$aurl\">".$aurl."</a><br \> ");
}
}
}
} else { printf("No url\n");}
?>
Вытягивает ссылки на картинки с html файла
+110
if (M[1]<>M[2]) and (M[1]<>M[3]) and (M[1]<>M[4]) and (M[1]<>M[5]) and (M[1]<>M[6]) then
begin
if (M[1]<>M[7]) and (M[1]<>M[8]) and (M[1]<>M[9]) and (M[1]<>M[10]) then
write(' ',M[1],' ');
end;
if (M[2]<>M[1]) and (M[2]<>M[3]) and (M[2]<>M[4]) and (M[2]<>M[5]) and (M[2]<>M[6]) then
begin
if (M[2]<>M[7]) and (M[2]<>M[8]) and (M[2]<>M[9]) and (M[2]<>M[10]) then
write(' ',M[2],' ');
end;
if (M[3]<>M[1]) and (M[3]<>M[2]) and (M[3]<>M[4]) and (M[3]<>M[5]) and (M[3]<>M[6]) then
begin
if (M[3]<>M[7]) and (M[3]<>M[8]) and (M[3]<>M[9]) and (M[3]<>M[10]) then
write(' ',M[3],' ');
end;
if (M[4]<>M[1]) and (M[4]<>M[2]) and (M[4]<>M[3]) and (M[4]<>M[5]) and (M[4]<>M[6]) then
begin
if (M[4]<>M[7]) and (M[4]<>M[8]) and (M[4]<>M[9]) and (M[4]<>M[10]) then
write(' ',M[4],' ');
end;
if (M[5]<>M[1]) and (M[5]<>M[2]) and (M[5]<>M[3]) and (M[5]<>M[4]) and (M[5]<>M[6]) then
begin
if (M[5]<>M[7]) and (M[5]<>M[8]) and (M[5]<>M[9]) and (M[5]<>M[10]) then
write(' ',M[5],' ');
end;
if (M[6]<>M[1]) and (M[6]<>M[2]) and (M[6]<>M[3]) and (M[6]<>M[4]) and (M[6]<>M[5]) then
begin
if (M[6]<>M[7]) and (M[6]<>M[8]) and (M[6]<>M[9]) and (M[6]<>M[10]) then
write(' ',M[6],' ');
end;
if (M[7]<>M[1]) and (M[7]<>M[2]) and (M[7]<>M[3]) and (M[7]<>M[4]) and (M[7]<>M[5]) then
begin
if (M[7]<>M[6]) and (M[7]<>M[8]) and (M[7]<>M[9]) and (M[7]<>M[10]) then
write(' ',M[7],' ');
end;
readln;
if (M[8]<>M[1]) and (M[8]<>M[2]) and (M[8]<>M[3]) and (M[8]<>M[4]) and (M[8]<>M[5]) then
begin
if (M[8]<>M[6]) and (M[8]<>M[7]) and (M[8]<>M[9]) and (M[8]<>M[10]) then
write(' ',M[8],' ');
end;
if (M[9]<>M[1]) and (M[9]<>M[2]) and (M[9]<>M[3]) and (M[9]<>M[4]) and (M[9]<>M[5]) then
begin
if (M[9]<>M[6]) and (M[9]<>M[7]) and (M[9]<>M[8]) and (M[8]<>M[10]) then
write(' ',M[9],' ');
end;
if (M[10]<>M[1]) and (M[10]<>M[2]) and (M[10]<>M[3]) and (M[10]<>M[4]) and (M[10]<>M[5]) then
begin
if (M[10]<>M[6]) and (M[10]<>M[7]) and (M[10]<>M[8]) and (M[10]<>M[9]) then
write(' ',M[10],' ');
end;
Циклы? Не, не слышал...
+67
<?if($metaid == 16 || $metaid == 44 || $metaid == 52 || $metaid == 60 || $metaid == 90 ||
$metaid == 132 || $metaid == 136 || $metaid == 174 || $metaid == 192 || $metaid == 196 ||
$metaid == 238 || $metaid == 388 || $metaid == 462 || $metaid == 470 || $metaid == 480 ||
$metaid == 500 || $metaid == 530 || $metaid == 533 || $metaid == 548 || $metaid == 580 ||
$metaid == 584 || $metaid == 662 || $metaid == 666 || $metaid == 678 || $metaid == 690 ||
$metaid == 772 || $metaid == 780 || $metaid == 833){?>на<?} else if($metaid == 250 ||
$metaid == 254 || $metaid == 258 || $metaid == 704){?>во<?}else{?>в<?}?>
Одно из пятнадцати подобных условий в файле. Было написано в одну строку, поэтому тело условия увидели не сразу. Разнес по строкам для удобства чтения.
+124
# Some old m4's don't support m4exit. But they provide
# equivalent functionality by core dumping because of the
# long macros we define.
ifdef([__gnu__], ,
[errprint(M4sugar requires GNU M4. Install it before installing M4sugar or
set the M4 environment variable to its path name.)
m4exit(2)])
из m4 скрипта, часть autoconf.
fyi: http://en.wikipedia.org/wiki/M4_%28computer_language%29
−165
$sql = 'SELECT * FROM
(SELECT COUNT(company.id) as cnt_company ,
FROM_DAYS(TO_DAYS( company.created_at )) as day
FROM company
JOIN contact ON contact.company_id = company.id
JOIN issuer ON issuer.id = company.issuer_id
JOIN bill ON bill.company_id = company.id
WHERE contact.partner_id ='.$this->_partner->getId().'
AND company.created_at '.$query.'
GROUP BY day) as A
LEFT JOIN
(SELECT COUNT(process.id) as finished,
FROM_DAYS(TO_DAYS( process.finished_at )) as day2
FROM process
JOIN bill on bill.id= process.bill_id
JOIN company ON bill.company_id = company.id
JOIN contact ON contact.company_id = company.id
JOIN issuer ON issuer.id = company.issuer_id
WHERE contact.partner_id ='.$this->_partner->getId().'
AND issuer.signature_article_id = bill.article_id
GROUP BY day2) as B ON A.day = B.day2
LEFT JOIN
(SELECT COUNT( * ) as count,
FROM_DAYS(TO_DAYS(click.created_at)) as day3,
COUNT( DISTINCT click.ip ) as uniq
FROM click
WHERE click.partner_id = '.$this->_partner->getId().'
AND click.created_at '.$query.'
GROUP BY day3) as C ON A.day = C.day3
UNION
SELECT * FROM
(SELECT COUNT(company.id) as cnt_company ,
FROM_DAYS(TO_DAYS( company.created_at )) as day
FROM company
JOIN contact ON contact.company_id = company.id
JOIN issuer ON issuer.id = company.issuer_id
JOIN bill ON bill.company_id = company.id
WHERE contact.partner_id ='.$this->_partner->getId().'
AND DATE(company.created_at)'.$query.'
GROUP BY day) as A
RIGHT JOIN
(SELECT COUNT(process.id) as finished,
FROM_DAYS(TO_DAYS( process.finished_at )) as day2
FROM process
JOIN bill on bill.id= process.bill_id
JOIN company ON bill.company_id = company.id
JOIN contact ON contact.company_id = company.id
JOIN issuer ON issuer.id = company.issuer_id
WHERE contact.partner_id ='.$this->_partner->getId().'
AND issuer.signature_article_id = bill.article_id
GROUP BY day2 ) as B ON A.day = B.day2
RIGHT JOIN
(SELECT COUNT( * ) as count,
FROM_DAYS(TO_DAYS(click.created_at)) as day3,
COUNT( DISTINCT click.ip ) as uniq
FROM click
WHERE click.partner_id = '.$this->_partner->getId().'
AND click.created_at '.$query.'
GROUP BY day3) as C ON A.day = C.day3';
T_T
+53
function CP1251toUTF8($string) {
$out = '';
for ($i = 0; $i < strlen($string); ++$i) {
$ch = ord($string{$i});
if ($ch < 0x80)
$out .= chr($ch);
else
if ($ch >= 0xC0)
if ($ch < 0xF0)
$out .= "\xD0" . chr(0x90 + $ch - 0xC0); // А-Я, а-п (A-YA, a-p)
else
$out .= "\xD1" . chr(0x80 + $ch - 0xF0); // р-я (r-ya)
else
switch ($ch) {
case 0xA8: $out .= "\xD0\x81";
break; // YO
case 0xB8: $out .= "\xD1\x91";
break; // yo
// ukrainian
case 0xA1: $out .= "\xD0\x8E";
break; // Ў (U)
case 0xA2: $out .= "\xD1\x9E";
break; // ў (u)
case 0xAA: $out .= "\xD0\x84";
break; // Є (e)
case 0xAF: $out .= "\xD0\x87";
break; // Ї (I..)
case 0xB2: $out .= "\xD0\x86";
break; // I (I)
case 0xB3: $out .= "\xD1\x96";
break; // i (i)
case 0xBA: $out .= "\xD1\x94";
break; // є (e)
case 0xBF: $out .= "\xD1\x97";
break; // ї (i..)
// chuvashian
case 0x8C: $out .= "\xD3\x90";
break; // ? (A)
case 0x8D: $out .= "\xD3\x96";
break; // ? (E)
case 0x8E: $out .= "\xD2\xAA";
break; // ? (SCH)
case 0x8F: $out .= "\xD3\xB2";
break; // ? (U)
case 0x9C: $out .= "\xD3\x91";
break; // ? (a)
case 0x9D: $out .= "\xD3\x97";
break; // ? (e)
case 0x9E: $out .= "\xD2\xAB";
break; // ? (sch)
case 0x9F: $out .= "\xD3\xB3";
break; // ? (u)
}
}
return $out;
}
iconv? Не, не слышал.