- 1
self._DEBUG=Debug.Debug(debug)
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−318
self._DEBUG=Debug.Debug(debug)
В библиотеке xmpppy. Дебаг на дебаге.
+96
Assign(F, FileName);
IOResult;
Reset(F);
if IOResult = 0 then begin
for i := 0 to MaxModelNamesCount-1 do ModelKind[i] := mkVagon;
Result := True;
BlockRead(F, W, 2);
if W = OldWDim then begin // старый формат
// 20 строк пропущено
end else if W = WDim then begin // новый формат
BlockRead(F, FormatVersion, 4); // версия нового формата
if FormatVersion <= 4 then begin
BlockRead(F, EditorDate, 4);
BlockRead(F, C, 4);
LCount := C;
for i := 0 to LCount - 1 do begin
BlockReadLine(F, Lines[i], 16);
if (FormatVersion <= 2) and (Lines[i].Attr[3] and $0F = 5) then Lines[i].Attr[0] := 0
else if (Lines[i].Attr[3] and $0F = k3DObject) then ModelKind[Lines[i].IntAttr[1]] := mkStatic;
end;
if FormatVersion <= 1 then begin
ModelNamesCount := 8; // для 1й версии список жёстко задан
ModelNames[0] := 'ГЗРВ-10';
ModelNames[1] := 'ГЗРВ-10М';
ModelNames[2] := 'КТМ-5М3';
ModelNames[3] := 'ЛМ-68';
ModelNames[4] := 'ЛМ-68М';
ModelNames[5] := 'ЛМ-68ММ';
ModelNames[6] := 'ЛВС-86';
ModelNames[7] := 'ЛВС-97';
for i := 8 to MaxModelNamesCount-1 do ModelNames[i] := '';
end else if FormatVersion <= 3 then begin
ModelNamesCount := 0;
for i := 0 to 255 do begin
j := 0;
BlockRead(F, j, 1);
SetLength(ModelNames[i], j);
for j := 1 to Length(ModelNames[i]) do Read(F, byte(ModelNames[i, j]));
if ModelNames[i] <> '' then Inc(ModelNamesCount);
end;
end else begin
BlockRead(F, ModelNamesCount, 4); // кол-во моделей
for i := 0 to MaxModelNamesCount - 1 do ModelNames[i] := '';
for i := 0 to ModelNamesCount-1 do begin
BlockRead(F, k, 4); // номер считываемой модели
j := 0;
BlockRead(F, j, 1); // длина имени, не более 255
SetLength(ModelNames[k], j);
for j := 1 to Length(ModelNames[k]) do Read(F, byte(ModelNames[k, j]));
end;
end;
for i := 0 to 8 do
for j := 0 to 12 + Byte(FormatVersion >= 2) do with Routes[i, j] do begin
BlockRead(F, PCount, 2);
SetAllowedModels(Routes[i,j], 0, -1);
if FormatVersion <= 1 then begin
BS := [];
BlockRead(F, BS, 4);
AllowedModelsCount := 0;
for k := 0 to 255 do if k in BS then begin
Inc(AllowedModelsCount);
AllowedModels[k] := True;
end;
end else if FormatVersion <= 3 then begin
BlockRead(F, BS, 32);
AllowedModelsCount := 0;
for k := 0 to 255 do if k in BS then begin
Inc(AllowedModelsCount);
AllowedModels[k] := True;
end;
end else begin
BlockRead(F, AllowedModelsCount, 4);
for k := 0 to AllowedModelsCount-1 do begin
BlockRead(F, n, 4); // номер модели
AllowedModels[n] := True;
end;
end;
for k := 0 to PCount - 1 do begin
if FormatVersion >= 3 then BlockRead(F, c, 4)
else begin
c := 0;
BlockRead(F, c, 2);
end;
Points[k] := c;
end;
BlockRead(F, DefVagons, 1);
SpeedRoute := boolean(DefVagons shr 4);
DefVagons := DefVagons and $0F;
BlockRead(F, Interval, 1);
end;
end else Result := False;
end else Result := False;
Close(F);
Короче, лапша из if FormatVesion такой-то...
Обратная совместимость формата файла.
Формату уже 4 года.
−99
<%= @album.playlist.gsub('
','<br />') %>
Тогда, видимо, не догадался написать "\n" :)
+138
auto ret;
ulong[] generateMobs() {
ushort counter = 0;
for(ulong id = 0; id < NUMBER_OF_MOBS; ++id) {
Mob bufferMob = get(id);
if ( bufferMob.habitat == hero.hero.heroLocalityType() && ((bufferMob.rating() <= hero.hero.rating())) ) {
suitable ~= id;
counter++;
}
}
ret = suitable;
suitable.length = 0; /// Im
suitable = null; /// FUCKIN'
delete suitable; /// DESTROY YOU!!!
return ret;
}
Вообще это язык Ди(D(digitalmars.com <-- разрабы языка). Зае... Достала всякая НЕ статичная хрень)
Вообще в Ди есть гарбадж коллектор...
+167
<a title="Главная" href="http://<?php echo $_SERVER['HTTP_HOST'].str_replace('\\', '', dirname($_SERVER['PHP_SELF'])); ?>">Главная</a>
нашел в одном проекте, я бы и не смог до такого додуматься
−99
Dim byteOut(64) As Byte
Dim i As Integer
Try
byteOut(0) = Len(outCName) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H0 'Box Number - 1
byteOut(5) = Len(outCName) + 1 'message size with null terminator
For i = 1 To Len(outCName) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outCName, i, 1))
Next
byteOut(Len(outCName) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outCName) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Try
byteOut(0) = Len(outWState) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H1 'Box Number - 1
byteOut(5) = Len(outWState) + 1 'message size with null terminator
For i = 1 To Len(outWState) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outWState, i, 1))
Next
byteOut(Len(outWState) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outWState) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
<..ещё один раз..>
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Try
byteOut(0) = Len(outWindC) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H3 'Box Number - 1
byteOut(5) = Len(outWindC) + 1 'message size with null terminator
For i = 1 To Len(outWindC) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outWindC, i, 1))
Next
byteOut(Len(outWindC) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outWindC) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Try
byteOut(0) = Len(outHum) + 5 'number bytes in output message
byteOut(1) = &H0 'should be 0 for NXT
byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
byteOut(3) = &H9 'Send Bluetooth
byteOut(4) = &H4 'Box Number - 1
byteOut(5) = Len(outHum) + 1 'message size with null terminator
For i = 1 To Len(outHum) 'copy bytes into output array
byteOut(i + 5) = Asc(Mid(outHum, i, 1))
Next
byteOut(Len(outHum) + 6) = &H0 'add null terminator
SerialPort1.Write(byteOut, 0, Len(outHum) + 7) 'send message
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Говнокод почти трёхлетней давности. Понадобилось мне посмотреть, как я реализовывал "общение" по блютусу с Mindstorms NXT, и напоролся на вот это...
+163
<?php echo '<?xml version="1.0" encoding="utf-8"?>';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="ru">
<head>
<title>День Победы! 66 лет со дня победы! 9 Мая!</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">body{background:#000;}h1{color:#ff5500;}</style>
</head>
<body>
<div style="text-align:center">
<div style="padding-top:28%"><h1><?php
class Main
{
var $timex;
var $month;
var $day;
var $year;
function win2uni($s)
{
$s = convert_cyr_string($s,'w','i');
for ($result='', $i=0; $i<strlen ($s); $i++) {
$charcode = ord($s[$i]);
$result .= ($charcode>175)?"&#".(1040+($charcode-176)).";":$s[$i];
}
return $result;
}
function Main()
{
if ($this->GetDate())
$this->TimeTo();
return true;
}
function GetDate()
{
$this->month = '05';
$this->day = '09';
$this->year = '2011';
return true;
}
function TimeTo()
{
$m = $this->month;
$d = $this->day;
$y = $this->year;
$mn = date("m");
$dn = date("d");
$yn = date("y");
$hh = date("H");
$mm = date("i");
$ss = date("s");
$diff = mktime(23,59,59,$m,$d,$y)-mktime($hh,$mm,$ss,$mn,$dn,$yn);
$days = $diff/60/60/24;
$hours = $diff/60/60 - intval($days)*24;
$minutes = $diff/60 - intval(intval($days*24)*60);
$seconds = $diff - intval(intval(intval($days*24*60))*60);
$text = "До Дня Победы (9 мая) осталось<br/>\n";
$text.= round($days);
$mins = round($days)."";
if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " дней "; else
if (
$mins[strlen($mins)-1] == "2"
or $mins[strlen($mins)-1] == "3"
or $mins[strlen($mins)-1] == "4")
$text.= " дня "; else
if($mins[strlen($mins)-1] == "1")
$text.= " день "; else
$text.= " дней ";
$text.= round($hours);
if (round($hours) == 1 or round($hours == 21)) $text.= " час "; else
if (round($hours) == 2 or round($hours) == 3 or round($hours) == 4 or round($hours) == 22 or round($hours) == 23) $text.= " часа ";
else $text.= " часов ";
$text.= round($minutes);
$mins = round($minutes)."";
if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " минут "; else
if (
$mins[strlen($mins)-1] == "2"
or $mins[strlen($mins)-1] == "3"
or $mins[strlen($mins)-1] == "4")
$text.= " минуты "; else
if($mins[strlen($mins)-1] == "1")
$text.= " минута "; else
$text.= " минут ";
$text.= round($seconds);
$mins = round($seconds)."";
if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " секунд "; else
if (
$mins[strlen($mins)-1] == "2"
or $mins[strlen($mins)-1] == "3"
or $mins[strlen($mins)-1] == "4")
$text.= " секунды "; else
if($mins[strlen($mins)-1] == "1")
$text.= " секунда "; else
$text.= " секунд ";
echo $text;
return true;
}
}
$X = new Main();
?></h1></div>
Заранее извиняюсь за "опять даты, опять php":)
Отсчет времени до 9 мая
http://dumpz.org/23155/
+144
if (navigator.appName != "Microsoft Internet Explorer") {
document.write(
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img0\">\n"+
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img1\">\n"+
"<a href=\"#\" onClick=\"window.move(2);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img2\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(3);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img3\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(4);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img4\"></A>\n"+
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img5\">\n"+
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img6\"><BR>\n"+
"
"<a href=\"#\" onClick=\"window.move(26);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img26\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(27);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img27\"></A><BR>\n"+
"<a href=\"#\" onClick=\"window.move(28);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img28\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(29);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img29\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(30);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img30\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(31);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img31\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(32);return false\" onMouseOver=\"window.status='';\n"+
"return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img32\"></A>\n"+
"<a href=\"#\" onClick=\"window.move(33);return false\" onMouseOver=\"window.status='';\n"+
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img47\">\n"+
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img48\"><BR>")
... До хуя таких строк
}
else {
document.write(
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img0\">\n"+
"<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img1\">\n"+
"<img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img2\" \n"+
"onClick=\"window.move(2);return false\">\n"+
"<img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img3\" \n"+
"onClick=\"window.move(3);return false\">\n"+
"<img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img4\" \n"+
"
... аналогично
Из каталога готовых скриптов EsayScript
+147
<?php
$this->phptal->id=$id;
$this->phptal->returnid=$returnid;
if(isset($params['catalogue']))
{
if(isset($params['category']))
{
if(isset($params['news']))
{
$nid=(int)$params['news'];
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventNewsDAO.php'));
$nldao=new EventNewsDAO($this);
$this->phptal->newsline=$nldao->get($nid);
echo $this->ProcessTalTemplate('admin/admin_newsline.tal.tpl');
}
else
{
$cid=(int)$params['catalogue'];
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
$cdao=new EventCatalogueDAO($this);
$this->phptal->catalogue=$cdao->get($cid);
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCategoryDAO.php'));
$ccdao=new EventCategoryDAO($this);
$this->phptal->categories=$ccdao->all($cid);
$ccid=(int)$params['category'];
$this->phptal->category=$ccdao->get($ccid);
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventNewsDAO.php'));
$ndao=new EventNewsDAO($this);
$this->phptal->news=$ndao->all($ccid);
echo $this->ProcessTalTemplate('admin/admin_news.tal.tpl');
}
}
else
{
$cid=(int)$params['catalogue'];
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
$cdao=new EventCatalogueDAO($this);
$this->phptal->catalogue=$cdao->get($cid);
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCategoryDAO.php'));
$ccdao=new EventCategoryDAO($this);
$this->phptal->categories=$ccdao->all($cid);
echo $this->ProcessTalTemplate('admin/admin_categories.tal.tpl');
}
}
else
{
require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
$cdao=new EventCatalogueDAO($this);
$this->phptal->catalogues=$cdao->all();
echo $this->ProcessTalTemplate('admin/admin_catalogues.tal.tpl');
}
я молодец. наговнокодил как школьник.
ветвистое ветвление + жуткая копипаста.
буду это рефакторить, когда в целом закончу базовую функциональность.
+157
$opdirbase=opendir(H.'sys/fnc');
while ($filebase=readdir($opdirbase))
{
if (eregi('\.php$',$filebase))
{
include_once(H.'sys/fnc/'.$filebase);
}
}
Вот так вот инклюдится код в одной в вап cms.В дериктории файлы по 200-300кб.