- 1
require File.expand_path(File.dirname(__FILE__) + '/../../../../../../usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb')
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−107
require File.expand_path(File.dirname(__FILE__) + '/../../../../../../usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb')
+163
<?
$cont = file_get_contents("http://www.cbr.ru/scripts/XML_daily.asp");
$pattern = "/<CharCode>(.*?)<\/CharCode>\s*<Nominal>(.*)<\/Nominal>\s*<Name>(.*)<\/Name>\s*<Value>(.*)<\/Value>/im";
$cnt = preg_match_all($pattern,$cont,$matches);
if($cnt != FALSE)
{
$count_currencies = count($matches[1]);
for($i=0;$i<$count_currencies;$i++)
{
$curr_abbr = $matches[1][$i];
$curr_nominal = $matches[2][$i];
$curr_name = $matches[3][$i];
$curr_value = $matches[4][$i];
echo "$curr_abbr - $curr_nominal - $curr_name - $curr_value <br>";
} // for
} // if($cnt != FALSE)
?>
после сдачи сайта разраб CMS спешно уволился.
+165
$sel = '';
for($i=90;$i<=250;$i++){
$sel.= "<option value=\"$i\"".(($i==100) ? ' selected' : '').">$i px</option>\n";
$i = $i + 9;
}
Код из Danneo CMS
+166
TagsTree ParseXML(const char file_name[])
{
ifstream input_file(file_name, std::ios::in);
string content;
if(!input_file.good())
{
throw "can't open xml";
}
while(!input_file.eof())
{
char buffer[256];
input_file.read(buffer, 256);
streamsize read_count = input_file.gcount();
content.append(buffer, buffer+read_count);
}
input_file.close();
auto Cleanup = [&content](const string& what_to_del) -> void
{
string::size_type pos = content.find(what_to_del);
while(pos != string::npos)
{
content.erase(pos, what_to_del.size());
pos = content.find(what_to_del, pos);
}
};
Cleanup("\n");
Cleanup("\t");
Cleanup(" ");
string::size_type comment_begin = 0;
string::size_type comment_end = 0;
for(;;)
{
string::size_type comment_begin = content.find("<!--", comment_end);
if(comment_begin == string::npos)
{
break;
}
string::size_type comment_end = content.find(">", comment_begin+3);
if(comment_end == string::npos)
{
throw "invalid xml: no comment closing brace";
}
content.erase(comment_begin, comment_end-comment_begin+1);
comment_end = comment_begin;
}
string::size_type header_begin = content.find("<?xml");
if(header_begin == string::npos)
{
throw "invalid xml: no header";
}
string::size_type header_end = content.find(">", header_begin+4);
if(header_end == string::npos)
{
throw "invalid xml: no header closing brace";
}
content.erase(comment_begin, header_end-header_begin+1);
auto CutTagAndContent = [](string& from, string& tag, string& content) -> void
{
string::size_type position = from.find('>');
if(position == string::npos)
{
throw "invalid xml: no tag closing brace";
}
tag = from.substr(1, position-1);
position = from.find("</"+tag+'>', position);
if(position == string::npos)
{
throw "invalid xml: no closing tag";
}
content = from.substr(tag.size()+2, position-tag.size()-2);
from.erase(0, position+tag.size()+3);
};
if(content[0] != '<')
{
throw "invalid xml: to root tag";
}
TagsTree result;
CutTagAndContent(content, result.Node.name, result.Node.content);
TagsTree::children_vectorT children;
children.push_back(&result);
do
{
for(auto i = children.begin(); i!= children.end(); i++)
{
while(!(**i).Node.content.empty())
{
if((**i).Node.content[0]!='<')
{
break;
}
TAG temporary;
CutTagAndContent((**i).Node.content, temporary.name, temporary.content);
(**i).Push(temporary);
}
}
children = EnlistChildren(children);
}
while(!children.empty());
return result;
}
Говнонедопарсер недоговноXML. Дерево тэгов - отдельная кучка.
+128
public void Dispose()
{
throw new NotImplementedException();
}
Студенты такие студенты
+123
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
<link rel="stylesheet" href="/ww.admin/theme/admin.css" type="text/css" />
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/south-street/jquery-ui.css" type="text/css" />
</head>
<body>
<div id="header">
<div id="menu-top">
<ul>
<li><a href="/ww.admin/pages.php">Pages</a></li>
<li><a href="/ww.admin/users.php">Users</a></li>
<li><a href="/ww.incs/logout.php?redirect=/ww.admin/">Log Out</a></li>
</ul>
</div>
</div>
<div id="wrapper">
<h1>Pages</h1><div class="left-menu"><script src="/j/jstree/jquery.jstree.js"></script>
<script src="/ww.admin/pages/menu.js"></script>
<div id="pages-wrapper"><ul><li id="page_1"><a href="pages.php?id=1"><ins> </ins>Home</a><ul><li id="page_2">
<a href="pages.php?id=2"><ins> </ins>Second Page</a></li></ul></li></ul></div></div>
<div class="has-left-menu"><h2>FORM GOES HERE</h2></div>
<style type="text/css"> @import "pages/css.css";</style></div>
</body>
</html>
+161
/**
* Корневая директория
*/
define('ROOT', dirname(dirname(dirname(__FILE__))) );
В случае 5.3 было бы на один раз короче... :P
+99
procedure TForm1.OvalButton1Click(Sender: TObject);
begin
Randomize;
Win := Random(2);
//////////////////////////////////
If Win = 1 then
Begin
NumericEdit1.Enabled := true;
OvalButton1.Enabled := false;
OvalButton2.Enabled := false;
Timer1.Enabled := false;
LEDMeter1.Position := 0;
LEDDisplay1.Value := 30;
Button1.Enabled := true;
chet := chet + Trunc(NumericEdit1.Value *2);
Memo1.Text := 'Поздравляю!';
Label1.Caption := IntToStr(Chet) + '$';
ShowMessage('Победа! Вы разминировали мину!');
End
else
Begin
NumericEdit1.Enabled := true;
OvalButton1.Enabled := false;
OvalButton2.Enabled := false;
Timer1.Enabled := false;
LEDMeter1.Position := 0;
LEDDisplay1.Value := 30;
Button1.Enabled := true;
Memo1.Text := 'Проигрыш!';
Label1.Caption := IntToStr(Chet) + '$';
ShowMessage('Вы проиграли!');
end;
end;
procedure TForm1.OvalButton2Click(Sender: TObject);
begin
Randomize;
Win := Random(2);
///////////////////////////////
If Win = 1 then
Begin
NumericEdit1.Enabled := true;
OvalButton1.Enabled := false;
OvalButton2.Enabled := false;
Timer1.Enabled := false;
LEDMeter1.Position := 0;
LEDDisplay1.Value := 30;
Button1.Enabled := true;
Memo1.Text := 'Проигрыш';
Label1.Caption := IntToStr(Chet) + '$';
ShowMessage('Вы проиграли!');
End
else
Begin
NumericEdit1.Enabled := true;
OvalButton1.Enabled := false;
OvalButton2.Enabled := false;
Timer1.Enabled := false;
LEDMeter1.Position := 0;
LEDDisplay1.Value := 30;
chet := chet + Trunc(NumericEdit1.Value *2);
Button1.Enabled := true;
Memo1.Text := 'Поздравляю!';
Label1.Caption := IntToStr(Chet) + '$';
ShowMessage('Победа! Вы разминировали мину!');
end;
end;
MOAR из серии оффлайн симуляторов.
+96
function OnShape(sh: TShape; X, Y: Integer) : TBrushStyle;
var r, cx, cy, d2: Integer;
begin
r := sh.Width div 2;
cx := sh.Left + r;
cy := sh.Top + r;
d2 := (X - cx) * (X - cx) + (Y - cy) * (Y - cy);
OnShape := bsClear;
if d2 < r*r then OnShape := bsSolid;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Shape1.Brush.Color := clRed;
Shape1.Brush.Style := OnShape(Shape1, X, Y);
Shape2.Brush.Color := clLime;
Shape2.Brush.Style := OnShape(Shape2, X, Y);
Shape3.Brush.Color := clYellow;
Shape3.Brush.Style := OnShape(Shape3, X, Y);
end;
Откуда бы вы думали это? Правильно, "Занимательное программирование Delphi". Глава 14. Светофор.
+155
{{if $remove_email eq "Y"}}
<script type="text/javascript">
if( confirm("Are you sure you want to delete email \"{{$email|escape}}\"?") )
document.location.href="http://{{$host}}/email.html?action=remove_email&confirm=Y";
</script>
{{/if}}
Смарти феерия продолжается. Теперь редиректы с яваскриптом