- 1
- 2
- 3
- 4
if (ch=='k' && ch!='t')
{
something
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+980
if (ch=='k' && ch!='t')
{
something
}
Найдено в довольно серьезном проекте.
+168
function eto_zifra(symbol)
93{
94var value_1=false;
95if(symbol=='0') value_1=true;
96if(symbol=='1') value_1=true;
97if(symbol=='2') value_1=true;
98if(symbol=='3') value_1=true;
99if(symbol=='4') value_1=true;
100if(symbol=='5') value_1=true;
101if(symbol=='6') value_1=true;
102if(symbol=='7') value_1=true;
103if(symbol=='8') value_1=true;
104if(symbol=='9') value_1=true;
105return value_1
106}
Сайт радиомагазина http://tda2000.ru/home/price
−131
#!/bin/bash
######################################################################################
#
# Write a bash script that obtains active processes for the current user,
# breaks them into chains and prints all unique chains containing 3 or more
# PIDs in the following format:
# PID1:PID2:PID3:…:PIDn
# PID:PID:PID:…:PID
# …
# So that each next PID is a parent of the previous PID, the first PID in
# each chain does not have children and the last PID in each chain
# does not have parent.
#
######################################################################################
TEMPFILE="/tmp/$0$$" # file needs to save the process list
# it's really needed to divide columns
# generated 'ps'
# parameters:
# -H - sorts the list as process forest (it lets to find connection between child and parent faster)
# -o - sets the output format
# "%p %P" - thow columns in output: PID and PPID
# -u - sets username
# `whoami` - get the current user name
ps -H -o "%p %P" -u `whoami` > $TEMPFILE
PIDLIST=(`awk '/[0-9]/ {print $1}' $TEMPFILE`) # make an array using the first column
PPIDLIST=(`awk '/[0-9]/ {print $2}' $TEMPFILE`) # and the second
SIZE=${#PIDLIST[*]}
K=0
# bypassing the forest using stack which emulates LINKS array. K is the pointer to stack's top
for (( i=0; i<$SIZE; i++ ))
do
if [[ $K = 0 || ${PPIDLIST[$i]} = ${LINKS[$K-1]} ]] # new tree or new edge in the tree.
then
LINKS[$K]=${PIDLIST[$i]} # push PID to stack
K=`expr $K + 1`
else # the chain is complete.
if [[ $K > 2 ]] # enough size to print the chain
then # reversed formatted output the chain
echo ${LINKS[*]} | awk '{ printf $NF; for (i = NF-1; i > 0; --i) printf ":"$i}'
echo
fi
until [[ $K == 0 || ${PPIDLIST[$i]} == ${LINKS[$K-1]} ]]
do # deleting elements from stack until find a
# parent or tree is end
unset LINKS[$K-1]
K=`expr $K - 1`
done
LINKS[$K]=${PIDLIST[$i]} # push PID to stack
K=`expr $K + 1`
fi
done
rm -rf $TEMPFILE # removing temp file
−116
-(BOOL) checkIsDeleted:(Transactions*)target
{
if (target.transactionType == TransactionTypeTransfer)
{
if (target.cashFlow && target.cashFlow.isDeleted && target.secondCashFlow && target.secondCashFlow.isDeleted)
return YES;
return NO;
}
else
if (target.cashFlow && target.cashFlow.isDeleted)
return YES;
return NO;
}
Классика )))
+161
$query = 'SELECT `views` FROM `'.PREFIX.'_newsi` WHERE `id` = '.$item["id"];
$result = $kernel->runSQL($query);
$count;
if (mysql_num_rows($result)) {
$count = mysql_result($result,"views");
$query = 'UPDATE `'.PREFIX.'_newsi` SET `views` = "'.++$count.'" WHERE `id` ='.$item["id"];
$kernel->runSQL($query);
}
Увеличиваем счетчик количества просмотров новости
+165
$month[1] = “Январ”;
$month[2] = “Феврал”;
$month[3] = “Март”;
$month[4] = “Апрел”;
$month[5] = “Ма”;
$month[6] = “Июн”;
$month[7] = “Июл”;
$month[8] = “Август”;
$month[9] = “Сентябр”;
$month[10] = “Октябр”;
$month[11] = “Декабр”;
$month[12] = “Январ”;
$day[0] = “Воскресенье”;
$day[1] = “Понедельник”;
$day[2] = “Вторник”;
$day[3] = “Среда”;
$day[4] = “Четверг”;
$day[5] = “Пятница”;
$day[6] = “Суббота”;
$dnum = date(”w”);
$mnum = date(”n”);
$daym = date(”d”);
$year = date(”Y”);
$textday = $day[$dnum];
$monthm = $month[$mnum];
if ($mnum==3||$mnum==8) {
$k=”а”;
}
else {
$k=”я”;
}
echo “Сегодня: $textday, $daym $monthm$k $year г.”;
Отсюда: http://flashripper.net/2007/10/24/delaem-vyvod-daty-na-php.html
−858
create or replace function t8() returns integer as $$
declare
rec record;
begin
for rec in select * from purchase loop
update purchase set amount=(
select book.cost*purchase.quantity*(1-customer.discount/100.0)
from purchase, book, customer
where purchase.id=rec.id and
book.id=purchase.book and
customer.id=purchase.customer
)
where purchase.id=rec.id;
end loop;
return 1;
end;
$$ language plpgsql;
select t8();
прочно засевшие в голове алгоритмические языки
−110
Public Class Decoder
Dim arr_en() As String = {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "?", "@"}
Dim arr_ua() As String = {"й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ъ", "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "є", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю", ".", ",", "'"}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Clear()
Dim t As Char
Dim ch As Char
Dim vv As String
For Each vv In TextBox1.Lines
For Each t In vv
For i As Integer = 0 To arr_en.Count - 1
ch = arr_en.GetValue(i)
If t = ch Then
t = arr_ua.GetValue(i)
Exit For
End If
Next
TextBox2.Text = TextBox2.Text & t
Next
TextBox2.Text = TextBox2.Text & vbCrLf
Next
End Sub
End Class
Декодер с английской раскладки за 5 минут.
+146
background-repeat: no-repeat no-repeat;
css css
+161
if(($n=func_num_args())>1)
{
$args=func_get_args();
if($n===2)
$object=new $type($args[1]);
else if($n===3)
$object=new $type($args[1],$args[2]);
else if($n===4)
$object=new $type($args[1],$args[2],$args[3]);
else
{
unset($args[0]);
$class=new ReflectionClass($type);
// Note: ReflectionClass::newInstanceArgs() is available for PHP 5.1.3+
// $object=$class->newInstanceArgs($args);
$object=call_user_func_array(array($class,'newInstance'),$args);
}
}
yii :)