- 1
http://rmd.atdmt.com/tl/DocumentDotWrite.js
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147.7
http://rmd.atdmt.com/tl/DocumentDotWrite.js
Оригинал http://thedailywtf.com/Articles/Amazingly-Brilliant-or-Incredibly-Stupid.aspx
+65.5
private static String getUTF8String(byte[] b, int off, int len) {
// First, count the number of characters in the sequence
int count = 0;
int max = off + len;
int i = off;
while (i < max) {
int c = b[i++] & 0xff;
switch (c >> 4) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
// 0xxxxxxx
count++;
break;
case 12: case 13:
// 110xxxxx 10xxxxxx
if ((int)(b[i++] & 0xc0) != 0x80) {
throw new IllegalArgumentException();
}
count++;
break;
case 14:
// 1110xxxx 10xxxxxx 10xxxxxx
if (((int)(b[i++] & 0xc0) != 0x80) ||
((int)(b[i++] & 0xc0) != 0x80)) {
throw new IllegalArgumentException();
}
count++;
break;
default:
// 10xxxxxx, 1111xxxx
throw new IllegalArgumentException();
}
}
if (i != max) {
throw new IllegalArgumentException();
....
В либе работы с зипом
+144.9
node_t* read_record(FILE *file) {
int success = 0;
node_t *record = 0;
do {
int nsz, dsz;
record = (node_t*)malloc(sizeof(node_t));
if (!record) {
break;
}
record->data = 0;
record->next = 0;
if (fread(&nsz, sizeof(int), 1, file) != 1 || feof(file)) {
break;
}
if (fread(record->name, 1, nsz, file) != nsz || feof(file)) {
break;
}
/* ... */
record->nsz = nsz;
record->dsz = dsz;
success = 1;
} while (0);
if (record && !success) {
free_list(record);
record = 0;
}
return record;
}
void write_record(FILE *file, node_t *record) {
int dsz = record->dsz;
int nsz = record->nsz;
if ((fwrite(&nsz, sizeof(int), 1, file) != 1) ||
(fwrite(record->name, 1, nsz, file) != nsz) ||
(fwrite(&csz, sizeof(int), 1, file) != 1) ||
(fwrite(record->data, 1, dsz, file) != dsz) ||
ferror(file)) {
fputs("Error: write_record", stderr);
}
}
+162.1
$cities_id=array(1,2,3,4,5,6);
$cities_name=array("MSK","SPB","NN","KZ","NOV","UFA");
GHTML::Run(array("html_autoinsert_on"=>0,"html_method"=>"_POST"));
print GHTML::Link("/test.php",null,GHTML::Link("/test.php","style='font-weight:bold;font-size:20px;'")->Html("[Главная]"))->Html("[Главная]");
print " ";
print GHTML::Link("/test.php?act=reg",null,GHTML::Link("/test.php?act=reg","style='font-weight:bold;font-size:20px;'")->Html("[Регистрация]"))->Html("[Регистрация]");
print GHTML::Form("POST","")
->HTML(
GHTML::Input("name","text","Имя пользователя",null,true)->Html(),
"<br>",
GHTML::Input("pass1","password","Пароль")->Html(),
"<br>",
GHTML::Input("pass2","password","Пароль ещё раз")->Html(),
"<br>",
GHTML::Select("city")->Html(
GHTML::Option("")->Html("Выберите город"),
GHTML::Option($cities_id,$_POST['city'])->Html($cities_name)
),
"<br>",
GHTML::CheckBoxList("che_cities[]",$cities_id,null,$_POST['che_cities'])->Html($cities_name),
"<br>",
GHTML::RadioList("r_cities[]",$cities_id,null,$_POST['r_cities'])->Html($cities_name),
"<br>",
GHTML::Textarea("resume",50,9,null,true)->Html("Ненмого о себе"),
"<br>",
GHTML::Input("","submit","Жми!")->Html()
);
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
<a href='/test.php' />[Главная]</a> <a href='/test.php?act=reg' style='font-weight:bold;font-size:20px;' />[Регистрация]</a><form method='POST' action='' /><input type='text' name='name' value='Имя пользователя' /><br><input type='password' name='pass1' value='Пароль' /><br><input type='password' name='pass2' value='Пароль ещё раз' /><br><select name='city' /><option value='' />Выберите город</option><option value='6' />MSK</option><option value='5' />SPB</option><option value='4' />NN</option><option value='3' />KZ</option><option value='2' />NOV</option><option value='1' />UFA</option></select><br><input type='checkbox' name='che_cities[]' value='6' />MSK<br /><input type='checkbox' name='che_cities[]' value='5' />SPB<br /><input type='checkbox' name='che_cities[]' value='4' />NN<br /><input type='checkbox' name='che_cities[]' value='3' />KZ<br /><input type='checkbox' name='che_cities[]' value='2' />NOV<br /><input type='checkbox' name='che_cities[]' value='1' />UFA<br /><br><input type='radio' name='r_cities[]' value='6' />MSK<br /><input type='radio' name='r_cities[]' value='5' />SPB<br /><input type='radio' name='r_cities[]' value='4' />NN<br /><input type='radio' name='r_cities[]' value='3' />KZ<br /><input type='radio' name='r_cities[]' value='2' />NOV<br /><input type='radio' name='r_cities[]' value='1' />UFA<br /><br><textarea name='resume' cols='50' rows='9' />Ненмого о себе</textarea><br><input type='submit' name='' value='Жми!' /></form>
хорошо что php гиппертекстовый ;)
+138.9
public static class Test3
{
public delegate object MyDelegate(object o);
public delegate T MyDelegate<T>(T o);
public static void Run()
{
MyDelegate dlgA = (o) => { return o; };
MyDelegate<object> dlgB = (i) => { return i; };
MyDelegate dlg = ChangeType<MyDelegate>(dlgB);
}
static T ChangeType<T>(Delegate dlg)
{
return (T)(object)Delegate.CreateDelegate(typeof(T), dlg.Target, dlg.Method);
}
}
Люблю вкусняшку))
−113.6
sub append {
my $appendstring = @_[0];
$returnstring = "$returnstring$appendstring";
}
Из плагина к nagios'у, который проверяет состояние интерфейсов на cisco-девайсах. http://svn.opsview.org/opsview/trunk/opsview-core/nagios-plugins/check_snmp_cisco_ifstatus .
+162
<?
$str = "";
$amp="";
foreach ($p as $i=>$v)
{
$str .= $amp."$i=$v";
$amp = "&";
}
?>
+106.6
if WordCount>GetWord(i) then else if WordCount>GetWord(i) then
begin
// ...
// ...
end;
при каких условиях выполнится код между begin-end?..
+171.6
if ( !empty( $page ) )
{
if ( $page == "login" )
{
$spage = "Login.inc";
}
else if ( $page == "rules" )
{
$spage = "rules.inc";
}
else if ( $page == "help" )
{
$spage = "help.inc";
}
else if ( $page == "wm" )
{
$spage = "wm.inc";
}
else if ( $page == "game"
{
$spage = "game.inc";
}
else if ( $page == "webmoney" )
{
$spage = "webmoney.inc";
}
else if ( $page == "egold" )
{
$spage = "egold.inc";
}
else if ( $page == "cashin" )
{
$spage = "cashin.inc";
}
else if ( $page == "ballans" )
{
$spage = "ballans.inc";
}
else if ( $page == "remind" )
{
$spage = "remind.inc";
}
else if ( $page == "contact" )
{
$spage = "contact.inc";
}
else if ( $page == "reg" )
{
$spage = "reg.inc";
}
:(((
+174.4
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
document.body.innerHTML = document.body.innerHTML.replace("[b]", "<b>");
document.body.innerHTML = document.body.innerHTML.replace("[/b]", "</b>");
bb-коды на индусском сайте