- 1
- 2
- 3
- 4
- 5
if request.path == '/':
thread_list = ThreadBlock.objects.all()
else:
thread_nomer = re.search( r'/\d*/', request.path ).group()[1:-1]
thread_list = ThreadBlock.objects.filter(id=int(thread_nomer))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−175
if request.path == '/':
thread_list = ThreadBlock.objects.all()
else:
thread_nomer = re.search( r'/\d*/', request.path ).group()[1:-1]
thread_list = ThreadBlock.objects.filter(id=int(thread_nomer))
Бидон, джанга, уеб.
+147
$offset = intval($_POST['offset']);
$sql = mysql_query("SELECT * FROM `test` ORDER BY id DESC LIMIT $offset, 5");
if(mysql_num_rows($sql)>0) {
while($post = mysql_fetch_assoc($sql)){
foreach($post AS $n=>$m){
$post[$n] = utf8_encode($m);
}
$json['more'][] = $post; # чтобы было легче до
}
if(count($json['more'])) {
$json['ok'] = '1';
} else {
$json['ok'] = '0';
}
} else {
$json['ok']='3';
}
mysql_close($db);
echo json_encode($json);
Индусский метод выборки записей из таблицы.
+161
class Session {
function sess_write() {
/*запись данных сессии в бд ($this->userdata)*/
}
function set_userdata($newdata = array(), $newval = '') {
if (count($newdata) > 0) {
foreach ($newdata as $key => $val) {
$this->userdata[$key] = $val;
}
}
$this->sess_write();
}
function unset_userdata($newdata = array()) {
if (count($newdata) > 0) {
foreach ($newdata as $key => $val) {
unset($this->userdata[$key]);
}
}
$this->sess_write();
}
function userdata($item) {
return (!isset($this->userdata[$item])) ? false : $this->userdata[$item];
}
}
говнокод изысканный.
ЗЫДН: в таком случае $this->sess_write() правильней делать в деструкторе
+125
for(int i = 0; i<et.Days.Count; i++)
{
if (et.Days[i].WorkDay.Day == colno - 1)
{
EmplTabelDays etd = et.Days[i];
switch (colno)
{
case 0:
break;
case 1:
break;
default:
{
//pinc.TypeIncome = (IncomeItem)
//((TreeNodeHelper)(income_grid.Rows[e.RowIndex].Cells[e.ColumnIndex]).Value).Value;
//etd.WorkStatus = (WorkStatus)((DataGridViewCell)(WorkDaysGrid.Rows[recno].Cells[colno]).Value).Value;
DataGridViewCell cell = WorkDaysGrid.Rows[recno].Cells[colno];
if (SpecialButton.Checked == false)
{
etd.TypeWorkHours = 8;
//еще 100500 строк гавнокода...
if (cell.Value == "8")
etd.WorkStatus.Id = 1;
if (cell.Value == "-")
etd.WorkStatus.Id = 2;
if (cell.Value == "О")
etd.WorkStatus.Id = 3;
if (cell.Value == "Б")
etd.WorkStatus.Id = 4;
if (cell.Value == "Р")
etd.WorkStatus.Id = 5;
if (cell.Value == "П")
etd.WorkStatus.Id = 6;
if (cell.Value == "А")
etd.WorkStatus.Id = 7;
if (cell.Value == "Г")
etd.WorkStatus.Id = 8;
if (cell.Value == "С")
etd.WorkStatus.Id = 9;
}
Найдено в коде программы табель для бухгалтерии.
Заполнение справочника с типами дней на основе ячеек грида.
KeyboardInheritance в чистом виде.
+120
// Check if You need Administrator-level access to create a folder
try
mkdir(SDirectory + '\~TEST');
except
on E: exception do
begin
if E.message = 'File access denied' then
begin
MessageBox(self.Handle,
'You need Administrator-level access to create this folder', '', MB_ICONERROR);
exit;
end;
end;
end;
RmDir(SDirectory + '\~TEST');
Мартышки плакали, кололись, но продолжали ронять UAC себе на лапки.
+168
$type = '';
if ($info[5]=='') $type.='0'; else $type.='1';
if ($info[6]=='') $type.='0'; else $type.='1';
if ($info[7]=='') $type.='0'; else $type.='1';
if ($type=='000') $type = '100';
Честно говоря я смотрел и пытался понять чего же человек этим добиться хотел... Это полный п%здец.
+147
if($response == false)
$response = true;
else
$response = false;
вот такая говно-конструкция изменяющая false на true и наоборот
−116
#!/bin/sh
#
# $1 is the mail account
[ -n "$1" ] && {
MAIL_PATH="/Mail/$1/mbox"
OUTPUT_MAIL_PATH="/mnt/flash/save/email/inbox/"
mkdir -p $OUTPUT_MAIL_PATH
mv /var/spool/mail/root/* $MAIL_PATH
for j in `find $MAIL_PATH -name "msg.*"`
do
MAIL_NAME=`basename $j`.eml
NEW_MAIL="$OUTPUT_MAIL_PATH/$MAIL_NAME"
mkdir -p "$OUTPUT_MAIL_PATH"
[ ! -f "$NEW_MAIL" ] && {
grep "^From:" $j | head -n 1 > $NEW_MAIL
if grep "^Cc:" $j ; then
grep "^Cc:" $j | head -n 1 >> $NEW_MAIL
fi
grep "^To:" $j | head -n 1 >> $NEW_MAIL
grep "^Subject:" $j | head -n 1 >> $NEW_MAIL
grep "^Date:" $j | head -n 1 >> $NEW_MAIL
if grep "^Content-Type: text/plain;" $j ; then
LINE_NUM=`grep -n "^Content-Type: text/plain;" $j | cut -d: -f1`
if grep "^Content-Type: text/plain;" $j | grep "charset=" ; then
TYPE=`grep "Content-Type: text/plain;" $j | cut -d";" -f1`
echo "$TYPE" >> $NEW_MAIL
CHAR="charset="`grep "Content-Type: text/plain;" $j | cut -d= -f2`
echo "$CHAR" >> $NEW_MAIL
else
grep "^Content-Type: text/plain;" $j >> $NEW_MAIL
x=$(($LINE_NUM+1))
sed -n "$x"p $j >> $NEW_MAIL
fi
x=$(($LINE_NUM-1))
BOUNDARY=`sed -n "$x"p $j`
for i in `sed "/$BOUNDARY/s/.*/ffffuuuucccckkkk/" $j | grep -n "ffffuuuucccckkkk" | cut -d: -f1`
do
if [ "$i" -gt "$LINE_NUM" ] ; then
i=$(($i-1))
y=$(($LINE_NUM+3))
echo "Mail content start:" >> $NEW_MAIL
sed -n "$y,$i"p $j >> $NEW_MAIL
break
fi
done
if ! grep "Mail content start:" $NEW_MAIL ; then
echo "Mail content start:" >> $NEW_MAIL
y=$(($LINE_NUM+3))
x=`grep -c "^" $j`
sed -n "$y,$x"p $j >> $NEW_MAIL
fi
else
echo "Fuck....."
fi
}
done
}
/bin/mail.sh из прошивки букридера GreenBook
+147
While ($componentPage != "ticket_edit")
$componentPage = "ticket_edit";
if ($componentPage == "ticket_edit")
$componentPage = "ticket_edit";
нет, я всё понимаю, но зачем такое насилие и контрольный в голову?
+162
$d_data = $engine->storageHandler->LoadData('TMSDiscipline',$tournament['discipline_id']);
$d_name = $d_data['name'];
$cs = 0;
if ($d_name[0] == 'C' && $d_name[1] == 'S'){
$cs = 1;
}
Определяем дисциплину матча.