- 1
http://nemolaboratory.ru/blog/about_a_miscellaneous/Nemo-Laboratory-About
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+144
http://nemolaboratory.ru/blog/about_a_miscellaneous/Nemo-Laboratory-About
Напишите здесь все свои замечания, буду благодарен
+129
if (obj == null)
return 0;
if (obj == DBNull.Value)
return 0;
return int.Parse (obj.ToString ());
в столбце хранится Integer...
+169
<?php
$res = "-1";
if($num>0) {
for($d=1;$d<=$num;$d++) {
$res.=",".$data[$d-1];
}
$res=substr($res,3,100000);
$res=str_replace(",",", ", $res);
}
?>
+165
$res = explode(" ", $price);
$price = trim(str_replace(".", "", str_replace(",", "", substr(trim($res[0]), 0, strlen(trim($res[0])) - 2))));
Изначально в переменной $price строка такого вида: 144.07 РУБ.
Судя по всему автор хотел таким образом получить из нее целое значение
−155
@image = (image unless image.nil?) or
(Rubygame::Surface.autoload(image_file) unless image_file.nil?) or
(Rubygame::Surface.autoload("#{@name}.png") unless @name.nil?) or
Rubygame::Surface.new([16, 16])
(c) http://stackoverflow.com/questions/3690508
+154
// $curr_page - старница, на который сейчас находимся
// $n_page - число страниц
// $count - обще число записей
// $param - site - страницы на сайте
// - adm - в админке
function genNumPage($curr_page, $n_page, $count, $param=null) {
$string = parse_url($_SERVER['REQUEST_URI']);
$query = '?'.$string['query'];
$num_page = ceil($count / $n_page);
if (isset($param)) $table = new my_Page("site/site_interface.html", "num_page");
else $table = new my_Page("interface/interface.html", "num_page");
if ($num_page < 2) return null;
for ($i = 1; $i <= $num_page; $i++) {
if ($i != $curr_page) {
if (preg_match('/\?p\=[0-9]{1,3}/', $query)) $href = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.$i, $query);
elseif (preg_match('/\&p\=[0-9]{1,3}/', $query)) $href = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.$i, $query);
elseif ($string['query'] != '') $href = '?'.$string['query'].'&p='.$i;
else $href = '?p='.$i;
if ((!$param) || ($param == 'adm')) $str .= " <a href=".$string['host'].$string['path'].$href.">".$i."</a> ";
else $str .= " <a href=".$string['host'].$string['path'].$href.">".$i."</a> | ";
}
elseif ((!$param) || ($param == 'adm')) $str .= "<span>".$i."</span>";
else $str .= "<span>".$i."</span> | ";
}
if ($curr_page > 1) {
if (preg_match('/\?p\=[0-9]{1,3}/', $query)) $prev = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.($curr_page - 1), $query);
elseif (preg_match('/\&p\=[0-9]{1,3}/', $query)) $prev = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.($curr_page - 1), $query);
elseif ($string['query'] != '') $prev = '?'.$string['query'].'&p='.($curr_page - 1);
else $prev = '?p='.($curr_page - 1);;
if ((!$param) || ($param == 'adm')) $prev = " <a href=".$string['host'].$string['path'].$prev." id=\"PrevLink\">←</a> ";
else $prev = " <a href=".$string['host'].$string['path'].$prev." id=\"PrevLink\">Предыдущая</a> ";
}
if ($curr_page < $num_page) {
if (preg_match('/\?p\=[0-9]{1,3}/', $query)) $next = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.($curr_page + 1), $query);
elseif (preg_match('/\&p\=[0-9]{1,3}/', $query)) $next = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.($curr_page + 1), $query);
elseif ($string['query'] != '') $next = '?'.$string['query'].'&p='.($curr_page + 1);
else $next = '?p='.($curr_page + 1);;
if ((!$param) || ($param == 'adm')) $next = " <a href=".$string['host'].$string['path'].$next." id=\"NextLink\">→</a> ";
else $next = " <a href=".$string['host'].$string['path'].$next." id=\"NextLink\">Следующая</a> ";
}
$table->addValueArray(array(
"NUM" => $str,
"PREV" => $prev,
"NEXT" => $next
));
return $table->myReplace();
}
Генерирует номера страниц. Из одной CMS'ки.
+165
class microTimer {
function start() {
global $starttime;
$mtime = microtime();
$mtime = explode( ' ', $mtime );
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
}
function stop() {
global $starttime;
$mtime = microtime();
$mtime = explode( ' ', $mtime );
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = round( ($endtime - $starttime), 5 );
return $totaltime;
}
}
DLE 9.0
+163
if (document.all('text1')!=null)
{
obj=document.all('text1');
obj.style.position='absolute';
obj.style.left=785+k;
obj.style.top=66;
}
if (document.all('text1')!=null)
{
obj=document.all('text2');
obj.style.position='absolute';
obj.style.left=785+k;
obj.style.top=88;
}
if (document.all('text1')!=null)
{
obj=document.all('img1');
obj.style.position='absolute';
obj.style.left=730+k;
obj.style.top=72;
}
if (document.all('text1')!=null)
{
obj=document.all('img2');
obj.style.position='absolute';
obj.style.left=904+k;
obj.style.top=84;
}
if (document.all('text1')!=null)
{
obj=document.all('img3');
obj.style.position='absolute';
obj.style.left=785+k;
obj.style.top=39;
}
if (document.all('text1')!=null)
{
obj=document.all('img4');
obj.style.position='absolute';
obj.style.left=795+k;
obj.style.top=109;
}
Надеюсь, что это генерировали в цикле, а не писали руками.
+167
$select->where('target_table.param IN (' . implode(',', array_map(create_function('$e', '{return "\'$e\'";}'), $entities)) . ')');
Недавно наткнулся на такое :)
−101
#TROLOLO GENERATOR!
def trololo(x):
print 'tro'+('lo'*x)
trololo(100)
Если нужно потроллить!