- 1
$date = mktime(0,0,0, date("m",time()), date("d",time()), date("Y",time()));
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+150.9
$date = mktime(0,0,0, date("m",time()), date("d",time()), date("Y",time()));
−100.4
{% if not has_previous %}
<a class="prev" style="visibility:hidden" href=?page={{ previous }} title="">prev</a>
{% else %}
<a class="prev" href=?page={{ previous }} title="">prev</a>
{% endif %}
Django template. Написал один знакомый.
+158.2
var TIWRECTANGLE14IWCL;
var TIWRECTANGLE17IWCL;
var TIWRECTANGLE18IWCL;
var TIWRECTANGLE19IWCL;
var TIWRECTANGLE16IWCL;
var TIWRECTANGLE15IWCL;
var TIWRECTANGLE10IWCL;
var TIWRECTANGLE12IWCL;
var TIWRECTANGLE13IWCL;
var TIWRECTANGLE11IWCL;
var TIWRECTANGLE9IWCL;
var TIWRECTANGLE7IWCL;
var TIWRECTANGLE8IWCL;
var TIWRECTANGLE1IWCL;
var TIWRECTANGLE4IWCL;
var TIWRECTANGLE6IWCL;
var TIWRECTANGLE5IWCL;
var TIWRECTANGLE3IWCL;
var TIWRECTANGLE2IWCL;
var IWEDIT1IWCL;
function IWEDIT2_OnKeyPress(ASender) {
return CheckReturnKey(event.keyCode, 'IWEDIT2', true);
}
Массивы - исчадие прих.больниц для неполноценных программистов!
Тру говнокодер пишет так!
Код веб-страницы на Делфи. Продолжение - http://govnokod.ru/1709
+48
while( !InputFileStream.atEnd() )
{
QString Qstrtmp;
InputFileStream >> Qstrtmp;
ReadButton.bTag = QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
InputFileStream >> Qstrtmp;
ReadButton.iTag = QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
InputFileStream >> Qstrtmp;
ReadButton.Popup = QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
ReadButton.PartitionId = *iVar;
this->Buttons.push_back( ReadButton );
}
Код взят из совместного проекта 5-ти студентов.
Это был начальный период нашего изучения Qt.
−105.1
def init_images():
rect = [[0,0],[0,0],[0,0],[0,0],[0,0]]
image = [[0,0],[0,0],[0,0],[0,0],[0,0]]
rect[0][0], image[0][0]=load_image('box.png')
rect[0][1], image[0][1]=load_image('box.png')
rect[1][0], image[1][0]=load_image('fpoint.png')
rect[1][1], image[1][1]=load_image('freefpoint.png')
rect[2][0], image[2][0]=load_image('spoint.png')
rect[2][1], image[2][1]=load_image('freespoint.png')
rect[3][0], image[3][0]=load_image('fbox.png')
rect[3][0], image[3][0]=load_image('fbox.png')
rect[4][0], image[4][0]=load_image('sbox.png')
rect[4][1], image[4][1]=load_image('sbox.png')
return image, rect
Процедура загрузки изображений. Т.к. программа писалась через силу (мозги не работали), получались вот такие жуткие куски кода...
+155.8
function ValidatorEnable(val, enable)
{
val.enabled = (enable != false);
ValidatorValidate(val);
ValidatorUpdateIsValid();
}
Обратите внимание на третью строку!
(Сначала кажется, что она ничего не делает, но на самом деле она переводит тип в boolean), но обычно пишут все-таки
val.enabled = !!enable
+158
for($i=$start; $i<$end; $i++) {
$v=$items[$idx[$i]];
}
$start = 0;
$end = count($items);
if (is_array($idx))
{
}
else
{
unset($idx);
$idx[0] = 0;
}
Хоть и вырвано из контекста, но общая красота от этого не теряется.
−55.1
#Пример раз
my %parse_hash = (
$sub_dir => $dir,
$sub_style_dir => $style_dir,
$sub_image_dir => $image_dir
);
#Пример два
...
elsif ($event eq $Event_View_Par){
print &ViewPar(%Query);
}
elsif ($event eq $Event_View_All){
print &ViewPar(%Query);
}
elsif ($event eq $Event_View_Asset){
print &ViewAsset(%Query);
}
Пример 1: В качестве ключей хэша переменные, которые определены в другом файле.
Пример 2: переменные $Event_View* определены в другом, используются только здесь и больше нигде
И так по всему коду
Задалбывает всё время переключаться alt-табом на файл, смотреть на определение переменных
−109.3
$in{item_name}=CGI::unescape($in{item_name});
$in{item_number}=CGI::unescape($in{item_number});
#убиваем пробелы сначала, с конца и двойные
###
if($in{item_name}=~/^[\s]+([\s\S]+)/) {
$in{item_name}=$1;
}
if($in{item_name}=~/([\s\S]+)[\s]+$/) {
$in{item_name}=$1;
}
$in{item_name}=~s/[\s]{2,}/ /g;
if($in{item_number}=~/^[\s]+([\s\S]+)/) {
$in{item_number}=$1;
}
if($in{item_number}=~/([\s\S]+)[\s]+$/) {
$in{item_number}=$1;
}
$in{item_number}=~s/[\s]{2,}/ /g;
####
my @select_parent=db_select_list ['title','id'],"catalog_section","parent_id=0";
###########
my $only_this_category_text;
my $checked_only;
if($in{action} eq 'filter' and !$in{only_this_cat}) { $checked_only=''; } else {$checked_only="checked"; }
#############################
my $selected_list_item;
my $only_this_cat_string;
my @selected_only;
my $selected_parent;
#die $in{only_this_cat_s};
for(@select_parent)
{my $name="index_sel_$$_{id}";
if($in{action} eq 'filter' and ($in{only_this_cat_s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
if(!$in{only_this_cat_s})
{ if(!$in{action} and ($in{s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
}else{ if($in{only_this_cat_s} eq $$_{id}){ $selected_only[$$_{id}]='selected';}}
}
############################
if($in{s}) {
#максимальная вложенность =3 - сформируем строку для чекбокса по-простому
my %ha=db_select_row ['id','title','parent_id'],"catalog_section","id=$in{s}";
if(%ha){$selected_only[$ha{parent_id}]='selected';}
my %parent=db_select_row ['title','parent_id'],"catalog_section","id=$ha{parent_id}";
my %parent2=db_select_row ['title','parent_id'],"catalog_section","id=$parent{parent_id}";
my $only_title=$ha{title};
$only_title= "$parent{title} — $only_title" if %parent;
$only_title= "$parent2{title} — $only_title" if %parent2;
$only_this_cat_string="";
if(%parent || %parent2) {#%ha
$only_this_category_text=qq~
<span>
<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
<label for="only_this_cat">Искать только в разделе «$only_title»</label>
</span>~;
}
}
$selected_list_item=qq~<select name="only_this_cat_s" id="only_this_cat_s"> <OPTION VALUE='none'>Все разделы</OPTION>~;
for(@select_parent)
{
$selected_list_item.=qq~<OPTION VALUE='$$_{id}' $selected_only[$$_{id}]~;
$selected_list_item.=qq~><label for="only_this_cat_s">$$_{title}</label>
</OPTION>~;
}
$selected_list_item.=qq~</select></td>~;
$only_this_cat_string="Раздел каталога";
Оригинальное форматирование сохранено
+148.7
// Any fool can write code that a computer can understand. Good programmers write code that humans can understand. (C) Martin Fowler.
function changeLogo() {
var pane = document.getElementById("pane");
if(pane != null) {
pane.height = 240;
pane.width = document.body.clientWidth;
} else {
alert("it's sad, so sad...");
}
var logo = document.getElementById("logoJpg");
if(logo != null) {
logo.height = 50;
logo.width = document.body.clientWidth * 0.23;
} else {
alert(" ...it's a sad, sad situation, and it's getting more and more absurd");
}
}
Код совсем ничего, но камменты рулят