- 1
$karkas = tr(bgcolor("D9EDFB"), td(w("1%").style("").valign("top"),br()).td(valign("top"), hr(noshade().size(1).color("D9EDFB")).table(cs(0).cp(10).border(0), tr(no(), td(no(), 'текст'...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+173
$karkas = tr(bgcolor("D9EDFB"), td(w("1%").style("").valign("top"),br()).td(valign("top"), hr(noshade().size(1).color("D9EDFB")).table(cs(0).cp(10).border(0), tr(no(), td(no(), 'текст'...
Все знают, что хорошим стилем написанием сайта является отделение кода от дизайна. Но то, что я увидел в самописной CMS, детище прошлого PHP-кодера, повергло меня в тихий ужас.
Каждый HTML-тег со всеми атрибутами был переопределён в отдельную функцию со своими параметрами. Нашлось место даже для замечательной функции br().
[url]http://ithappens.ru/story/3663[/url]
+157
<?
@$ok=$HTTP_POST_VARS["ok"];
@$user=$HTTP_POST_VARS["user"];
@$pwd=$HTTP_POST_VARS["pwd];
if(!isset($ok))
echo "<form action=.$2.php. method=POST>"
."Name<input type=text name user><br>"
."Password<input type=password name=pwd><br>"
."<input type=submit name=ok value=Войти>"
."</form>";
else
{
if(($user="Demo")&&($pwd=="Demo"))
echo "Wellcome";
else
echo "Access Blocked";
}
?>
Говорят, что это не говнокод.
+135
int Xor4Bit_2 (unsigned char data)
{
unsigned char result = data;
while (data != 0)
{
result ^= data & 1;
data >>= 1;
}
result &= 1;
return result;
}
вот как студенты получают xor битов числа
это же нужно так извратить простой рабочий алгоритм
int Xor4Bit_2 (unsigned char data)
{
int result = 0
while (data != 0)
{
result ^= data & 1;
data >>= 1;
}
return result;
}
получил данный код после измышлизмов знакомого студента, перед этим дав ему рабочий вариант, мдя...
+170
require_once('configure.php');
require('configure.php');
надо быть _увереным_ в своем коде
+80
private String nextUTF8Character() throws IOException, CharacterCodingException
{
int iCodePoint = 0;
int byte1, byte2, byte3, byte4;
byte1 = is.read();
if (byte1 == -1)
return null;
// проверяем является ли первый бит нулевым
if ((byte1 & 0x80) == 0)
{
// один байт
iCodePoint = byte1 & 0x7F;
return new String(Character.toChars(iCodePoint));
}
byte2 = is.read();
if (byte2 == -1)
return null;
if ((byte1 & 0xE0) == 0xC0 && (byte2 & 0xC0) == 0x80)
{
// два байта
iCodePoint = ((byte1 & 0x1F) << 6) | (byte2 & 0x3F);
if (iCodePoint > 0x7F)
return new String(Character.toChars(iCodePoint));
else
throw new CharacterCodingException();
}
byte3 = is.read();
if (byte3 == -1)
return null;
if ((byte1 & 0xF0) == 0xE0 && (byte2 & 0xC0) == 0x80 && (byte3 & 0xC0) == 0x80)
{
// три байта
iCodePoint = ((byte1 & 0x0F) << 12) | ((byte2 & 0x3F) << 6) | (byte3 & 0x3F);
if (iCodePoint > 0x7FF)
return new String(Character.toChars(iCodePoint));
else
throw new CharacterCodingException();
}
byte4 = is.read();
if (byte4 == -1)
return null;
if ((byte1 & 0xF8) == 0xF0 && (byte2 & 0xC0) == 0x80 &&
(byte3 & 0xC0) == 0x80 && (byte4 & 0xC0) == 0x80)
{
// четыре байта
iCodePoint = ((byte1 & 0x07) << 18) | ((byte2 & 0x3F) << 12) |
((byte3 & 0x3F) << 6) | (byte4 & 0x3F);
if (iCodePoint > 0x0FFFF)
return new String(Character.toChars(iCodePoint));
else
throw new CharacterCodingException();
}
throw new CharacterCodingException();
}
Мегаоптимизированный код для получения букафф в кодироффке UTFфф-8
По данным профилировщика именно этот фрагмент самый тормозной в моей сетевой проге
+97
/// До этой строчки еще больше 1000 строк кода (И это всё в ОДНОЙ процедур)
finally
if Main.RecordCount > 0
then Main.First;
Main.EnableControls;
Panel2.Color:=clLime;
lbTimeSpend.Caption:='Âðåìÿ çàòðà÷åíî:'+TimeToStr(time()-TimeWork);
end;
Exit;
try
if TmpCollect_Skd.IsSelectAll then
begin
Askd_count := TmpCollect_Skd.RxDBGrid1.DataSource.DataSet.RecordCount;
end
/// После этой строки еще более 1000 строк кода всё в этой же процедуре!
Продолжим. Вот так люди используют Exit;
+144.9
class SmoothingModeManager
{
public:
SmoothingModeManager(Context* context, Gdiplus::SmoothingMode mode = Gdiplus::SmoothingModeHighQuality);
virtual ~SmoothingModeManager();
protected:
Context* context_;
};
////////////////////////
SmoothingModeManager::SmoothingModeManager(Context* context, Gdiplus::SmoothingMode mode)
: context_(context)
{
context_->getCanvas()->SetSmoothingMode(mode);
}
SmoothingModeManager::~SmoothingModeManager()
{
context_->getCanvas()->SetSmoothingMode(Gdiplus::SmoothingModeNone);
}
Инициализируем класс и контекст со сглаживанием до конца метода.
+55.3
#include<iostream>
#include<math.h>
//#include<csdio>
using namespace std;
void main(){
//char*s1=new char[0]
int i=0;
do
char*s1=new char[0];
cout<<'write s1: ';
cin>>s1[i];
i=i+1;
while (*s1[i]=="\0");
for(int j=1, j==i, j++)
cout<<s1[j];
cout<<endl;
delete []s1;
}
Вот такую поделку мне прислали на проверку с жалобой "не работает".
+122.4
/* sent by Stephan Hughson - 2003 */
/* must be compiled with cc or g++*/
#include <stdio.h>
int main(int t,int _,char*a)
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
Вот результат работы программы(всё не вместилось):
On the first day of Christmas my true love gave to me
a partridge in a pear tree.
On the second day of Christmas my true love gave to me
two turtle doves
and a partridge in a pear tree.
...
On the eighth day of Christmas my true love gave to me
eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
On the ninth day of Christmas my true love gave to me
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
On the tenth day of Christmas my true love gave to me
ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
On the eleventh day of Christmas my true love gave to me
eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
On the twelfth day of Christmas my true love gave to me
twelve drummers drumming, eleven pipers piping, ten lords a-leaping,
nine ladies dancing, eight maids a-milking, seven swans a-swimming,
six geese a-laying, five gold rings;
four calling birds, three french hens, two turtle doves
and a partridge in a pear tree.
+27
$res["LIST_PAGE_URL"] = str_replace("//", "/", str_replace("#LANG#", $res["LANG_DIR"],
str_replace("#SITE_DIR#", SITE_DIR,
str_replace("#SERVER_NAME#", SITE_SERVER_NAME,
str_replace("#IBLOCK_ID#", $res["IBLOCK_ID"], $res["LIST_PAGE_URL"])
)
)
)
);
битрикс