- 1
- 2
- 3
- 4
- 5
- 6
$update_result = mysql_query($update) or die("failed");
if($update_result != false)
header("location: index.php");
else
die("Something Failed.");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+65
$update_result = mysql_query($update) or die("failed");
if($update_result != false)
header("location: index.php");
else
die("Something Failed.");
−32
//
// std::string wrapper
//
namespace priv {
class string {
std::string &m_s;
std::string &(std::string::*m_pAssign1)( const char *, std::string::size_type );
std::string &(std::string::*m_pAssign2)( const char * );
public:
string( std::string &str ): m_s(str),
m_pAssign1(&std::string::assign), m_pAssign2(&std::string::assign) {}
string &assign( const char *s, std::string::size_type n )
{
(m_s.*m_pAssign1)( s, n ); return *this;
}
string &assign( const char *s )
{
(m_s.*m_pAssign2)( s ); return *this;
}
};
}
сегодня ассимилирую старый хлам на работе (проекты VC6) в студию с нормальными свойствами проектов, конфигурациями, неабсолютными путями и т.д.
наткнулся в одной из либ на вот это
+123
#include <stdio.h>
int getLen(long long num)
{
int count=0;
while (num > 0)
{
count++;
num/=10;
}
return count;
}
int main(void)
{
int count = 0;
for (long long i=1; i<=9; i++)
{
long long num = 1;
int modify=0;
for (int j=1; j<30; j++)
{
if (i==7 && j == 5)
{
int a= 1;
a++;
}
num *= i;
if (getLen(num) == j-modify)
{
printf("%d^%d=%lld OK %d\n", i, j, num, count+1);
count++;
}
if (num > 10000000)
{
num/=10;
modify++;
}
}
}
printf("%d\n", count);
return 0;
}
http://projecteuler.net/problem=63
http://projecteuler.net/thread=63&page=8
>I don't want to write again an big number rendering algorithm, so I played a little trick on it and hoped it won't cause any trouble..
+112
switch (SelectedCategory)
{
case "Landscapers":
inputSearch.Value = "Landscapers";
break;
case "Baby sitters":
inputSearch.Value = "Baby sitters";
break;
case "Doctor":
inputSearch.Value = "Doctor";
break;
case "Cleaning services":
inputSearch.Value = "Cleaning services";
break;
case "Pet sitters":
inputSearch.Value = "Pet sitters";
break;
case "Handyman":
inputSearch.Value = "Handyman";
break;
case "Electrical services":
inputSearch.Value = "Electrical services";
break;
case "Tutor":
inputSearch.Value = "Tutor";
break;
case "Dog walker":
inputSearch.Value = "Dog walker";
break;
case "Plumbing":
inputSearch.Value = "Plumbing";
break;
case "Caterers":
inputSearch.Value = "Caterers";
break;
case "Misc":
inputSearch.Value = "Misc";
break;
}
обычный switch
−37
int LoggingProvider::AddJournalPackingLogRecord(int eventId, const astring& userId,
const std::vector<std::string>& journals, int errorId, int devCode,
int sysCode, const astring& errorArgs)
{
std::string strUserId(userId.c_str()), strErrorArgs(errorArgs);
return AddJournalPackingLogRecord(eventId, userId, journals, errorId, devCode, sysCode, strErrorArgs);
}
Рекурсия!
−96
while true
do
if [ $variable -le $null ]; then #### if then 1
vmm=`expr $vmm + 1`
if [ $vmm -eq `expr 13` ]; then
vmm=`expr 1`
fi
imm=`expr $imm - 1`
if [ $imm -eq $null ]; then
imm=`expr 12` vyy=`expr $vyy + 1`
fi
idd=`expr ${month[$imm]} + $variable`
if [ $idd -gt $null ]; then
if [ $imm -lt 10 ]; then
imm=0$imm
fi
if [ $idd -lt 10 ]; then
idd=0$idd
fi
calc_date=`expr $current_year - $vyy`$imm$idd
break;
else #### else 1
variable=`expr ${month[$imm]} + $variable`
fi
else
if [ $imm -lt 10 ]; then
vmm=0$imm
else
vmm=$imm
fi
if [ $variable -lt 10 ]; then
variable=0$variable
fi
calc_date=`expr $current_year - $vyy`$vmm$variable
break;
fi
done
echo $calc_date
#Альтернативный (нормальный) вариант
calc_date=`perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-'$period*86400';'`
Дата и время в нужном формате
+155
var nav = document.getElementById('navigation');
var properties = {
'display' : 'block',
'position' : 'fixed',
'top' : '5px',
'backgroundColor' : '#F2F0E3',
'opacity' : '.6',
........
//Много всяких свойств
........
'border' : '2px solid #DDDDDD',
'borderRadius' : '1em',
'padding' : '5px',
'zIndex' : '1'
}
for (var i in properties) {
nav.style[i] = properties[i];
}
Послать бы автора на три буквы: CSS
−118
SELECT x.org_spec_id, (
SELECT count(c.id) FROM customers c , government_customers_require gcr
WHERE c.org_spec_id=x.org_spec_id AND gcr.customer_id=c.id
) as bal_ins,
sum(x.type_b1) as type_b1, sum(x.type_b2) as type_b2, sum(x.type_b3) as type_b3, sum(x.bus_debit) as bus_debit,
sum(x.gost_ac1) as gost_ac1, sum(x.gost_ac2) as gost_ac2, sum(x.nav_ac1) as nav_ac1, sum(x.nav_ac2) as nav_ac2,
\'-\' as price1, \'-\' as price2, \'-\' as price3, \'-\' as price4, sum(x.scope_b1) as scope_b1,
sum(x.scope_b2) as scope_b2, sum(x.scope_b3) as scope_b3, sum(x.scope_b4) as scope_b4, sum(x.scope_b5) as scope_b5,
sum(x.scope_b6) as scope_b6, sum(x.add11) as add11, sum(x.add12) as add12, sum(x.add21) as add21,
sum(x.add22) as add22, sum(x.add23) as add23, sum(x.add31) as add31, sum(x.add32) as add32, sum(x.add33) as add33
FROM (SELECT c.org_spec_id, b.id , c.id as bal_ins,
case when bsd.id is not null then 1 else 0 end as bus_debit,
case when bsd.id is null then case when bm.type_id = 1 then 1 else 0 end else 0 end as type_b1,
case when bsd.id is null then case when bm.type_id = 2 then 1 else 0 end else 0 end as type_b2,
case when bsd.id is null then case when bm.type_id = 3 then 1 else 0 end else 0 end as type_b3,
case when bsd.id is null AND bm.type_id = 1 then case when gst.accepted then 1 else 0 end else 0 end as gost_ac1,
case when bsd.id is null AND bm.type_id = 1 then case when gst.accepted then 0 else 1 end else 0 end as gost_ac2,
case when bsd.id is null AND bm.type_id = 1 then case when nav.id is not null then 1 else 0 end else 0 end as nav_ac1,
case when bsd.id is null AND bm.type_id = 1 then case when nav.id is not null then 0 else 1 end else 0 end as nav_ac2,
case when bsd.id is null AND b.scope_id = 2 then 1 else 0 end as scope_b1,
case when bsd.id is null AND b.scope_id = 1 then 1 else 0 end as scope_b2,
case when bsd.id is null AND b.scope_id = 3 then 1 else 0 end as scope_b3,
case when bsd.id is null AND b.scope_id = 4 then 1 else 0 end as scope_b4,
case when bsd.id is null AND b.scope_id = 6 then 1 else 0 end as scope_b5,
case when bsd.id is null AND b.scope_id = 5 then 1 else 0 end as scope_b6,
case when bsd.id is null then case when add1.id is not null then case when add1.selected_variant=\'on\' then 1 else 0 end else 1 end else 0 end as add11,
case when bsd.id is null then case when add1.id is not null then case when add1.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add12,
case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'on\' then 1 else 0 end else 0 end else 0 end as add21,
case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add22,
case when bsd.id is null then case when add2.id is not null then case when add2.selected_variant=\'no\' then 1 else 0 end else 1 end else 0 end as add23,
case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'on\' then 1 else 0 end else 0 end else 0 end as add31,
case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'off\' then 1 else 0 end else 0 end else 0 end as add32,
case when bsd.id is null then case when add3.id is not null then case when add3.selected_variant=\'no\' then 1 else 0 end else 1 end else 0 end as add33
+66
Как вас зовут?
+66
if ($dt && $eventtype != 5 && $eventtype != 7) {
$sql_cond = " and b.datefrom='$dt'";
}
if ($eventtype == 5 || $eventtype == 7) {
if (!$dt || $dt == "0") {
$w = date("w");
$mon_dl = 7 - $w;
for ($j = 0; $j <= (7 - $w); $j++) {
$d = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
$dates .= ($dates ? "," . $d : $d);
}
if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
}
if ($dt == "1") {
$w = date("w");
if ($w == 0) {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
} else {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
}
for ($j = 0; $j <= 6; $j++) {
$d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
$dates .= ($dates ? "," . $d : $d);
}
if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
}
if ($dt == "2") {
$w = date("w");
if ($w == 0) {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
} else {
$monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
}
for ($j = 7; $j <= 13; $j++) {
$d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
$dates .= ($dates ? "," . $d : $d);
}
if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
}
}
я потерял сон.