- 1
- 2
- 3
public String toString() {
return new String(body.toString());
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+98
public String toString() {
return new String(body.toString());
}
Но зачем?
+127
if(Normal(Pawn.Acceleration) Dot Vect(1,0,0) > 0)
{
tempRot.Yaw = 0;
Pawn.SetRotation(tempRot);
}
Из туториала по UDK. Почему просто не написать Pawn.Acceleration > 0 ?
+126
infixr 6 `then'`
then' True = fst
then' False = snd
if' = id
else' suc fail = (suc, fail)
main = do
print $ if' (1<5) `then'` "true" `else'` "false"
print $ if' False `then'` "true" `else'` "false"
bormand
У ифа особый синтаксис. Как ты его реализуешь?
Challenge accepted:
Сначала был тред
http://govnokod.ru/12068#comment159236
а потом родилось говно:
http://ideone.com/rOKDPP
Реализовал if. За правильными приоритетами операций и ассоциативностью не следил.
+122
data IdPState a r = IdPEnd r | IdPNeedInput | IdPHaveInput a
{-# INLINE_STREAM idP #-}
idP :: (Monad m) => Stream l a a r m r
idP = Stream next IdPNeedInput where
{-# INLINE_INNER next #-}
next (IdPEnd r) = Done r
next IdPNeedInput = NeedInput IdPHaveInput IdPEnd
next (IdPHaveInput a) = HaveOutput IdPNeedInput (return ()) a
{-# INLINE_STREAM pipe #-}
pipe :: Monad m => Stream l a b r0 m r1 -> Stream Void b c r1 m r2 -> Stream l a c r0 m r2
pipe (Stream nextL sL) (Stream nextR sR) = Stream next (Right (return (), sL, Right sR)) where
{-# INLINE_INNER next #-}
next (Left r) = Done r
next (Right (final, sL, Right sR)) = case nextR sR of
Skip sR' -> Skip (Right (final, sL, Right sR'))
HaveOutput sR' c o -> HaveOutput (Right (final, sL, Right sR')) (c >> final) o
NeedInput p c -> Skip (Right (final, sL, Left (p, c)))
Done r -> PipeM (final >> return (Left r))
PipeM ms -> PipeM (liftM (Right . (final, sL,) . Right) ms)
Leftover _ i -> absurd i
next (Right (final, sL, Left (p, c))) = case nextL sL of
Skip sL' -> Skip (Right (final, sL', Left (p, c)))
HaveOutput sL' final' o -> Skip (Right (final', sL', Right (p o)))
NeedInput pL cL -> NeedInput (Right . (final,, Left (p, c)) . pL) (Right . (final,, Left (p, c)) . cL)
Done r -> Skip (Right (return (), sL, Right (c r)))
PipeM ms -> PipeM (liftM (Right . (final,, Left (p, c))) ms)
Leftover sL' i -> Leftover (Right (final, sL', Left (p, c))) i
{-# INLINE_STREAM purePipe #-}
purePipe :: (forall m . Monad m => Stream l a b r0 m r1) -> (forall m . Monad m => Stream Void b c r1 m r2) -> (forall m . Monad m => Stream l a c r0 m r2)
purePipe (Stream nextL sL) (Stream nextR sR) = Stream next (sL, Right sR) where
{-# INLINE_INNER next #-}
next (sL, Right sR) = case nextR sR of
Skip sR' -> Skip (sL, Right sR')
HaveOutput sR' _ o -> HaveOutput (sL, Right sR') (return ()) o
NeedInput p c -> Skip (sL, Left (p, c))
Done r -> Done r
PipeM ms -> Skip (sL, Right (runIdentity ms))
Leftover _ i -> absurd i
next (sL, Left (p, c)) = case nextL sL of
Skip sL' -> Skip (sL', Left (p, c))
HaveOutput sL' _ o -> Skip (sL', Right (p o))
NeedInput pL cL -> NeedInput ((, Left (p, c)) . pL) ((, Left (p, c)) . cL)
Done r -> Skip (sL, Right (c r))
PipeM ms -> Skip (runIdentity ms, Left (p, c))
Leftover sL' i -> Leftover (sL', Left (p, c)) i
+42
objbase.h:
#define __STRUCT__ struct
#define interface __STRUCT__
спасибо Микрософт за счастливое детство соответствие стандарту при засирании глобального неймспейса своими больными фантазиями
+141
public string Search(string title)
{
List<string> str1 = new List<string>();
string count = cmainlibrary.Count.ToString();
int counter = Convert.ToInt32(count);
int i = 0;
for ( i = 0; i < counter; i++)
{
string title_library = cmainlibrary[i].Title.ToString();
if (title.ToUpper().Contains(title_library. ToUpper()))
{
str1.Add(cmainlibrary[i].Title);
}
}
return str1[i];
}
Хотя я это выкладывал в коментариях к говнокоду #11830, решил повеселить народ отдельным постом.
Это реализация библиотеки книг. Метод должен искать список книг которые соответствуют title.
+42
std::string loc =
( {
const char *str = "";
switch (location) {
case Net::HANDSHAKE_TIMEOUT:
str = _(" due to handshake timeout");
break;
case Net::RECV_HANDSHAKE:
str = _(" while waiting for handshake");
break;
case Net::HANDSHAKE_DATA:
str = _(" due to unsupported handshake data");
break;
case Net::HANDSHAKE_AUTH:
str = _(" while parsing handshake data");
break;
case Net::WAIT_DEVICE:
str = _(" while waiting for device");
break;
case Net::TRANSFER_DATA:
str = _(" while transferring data");
break;
}
str;
});
Я хуею с юных оптимизаторов.
+133
if ((textBox1.Text == textBox2.Text) | (textBox1.Text == textBox3.Text) | (textBox1.Text == textBox4.Text) | (textBox1.Text == textBox7.Text) |
(textBox2.Text == textBox1.Text) | (textBox2.Text == textBox3.Text) | (textBox2.Text == textBox5.Text) | (textBox2.Text == textBox8.Text) |
(textBox3.Text == textBox1.Text) | (textBox3.Text == textBox2.Text) | (textBox3.Text == textBox6.Text) | (textBox3.Text == textBox9.Text) |
(textBox4.Text == textBox5.Text) | (textBox4.Text == textBox6.Text) | (textBox4.Text == textBox1.Text) | (textBox4.Text == textBox7.Text) |
(textBox5.Text == textBox4.Text) | (textBox5.Text == textBox6.Text) | (textBox5.Text == textBox2.Text) | (textBox5.Text == textBox8.Text) |
(textBox6.Text == textBox4.Text) | (textBox6.Text == textBox5.Text) | (textBox6.Text == textBox3.Text) | (textBox6.Text == textBox9.Text) |
(textBox7.Text == textBox8.Text) | (textBox7.Text == textBox9.Text) | (textBox7.Text == textBox1.Text) | (textBox7.Text == textBox4.Text) |
(textBox8.Text == textBox7.Text) | (textBox8.Text == textBox9.Text) | (textBox8.Text == textBox2.Text) | (textBox8.Text == textBox5.Text) |
(textBox9.Text == textBox7.Text) | (textBox9.Text == textBox8.Text) | (textBox9.Text == textBox3.Text) | (textBox9.Text == textBox6.Text)) ;
else
}
label1.Visible = true;
label2.Visible = true;
}
Это эпик.
+65
$quGroup = mysql_query($x = "
SELECT
a.latitude, a.longitude, a.catid, a.id, a.title, a.arttype, a.userid, b.firstname, b.lastname, b.usertype,
a.latitude2, a.longitude2, a.latitude3, a.longitude3, a.latitude4, a.longitude4, a.latitude5, a.longitude5,
a.latitude6, a.longitude6, a.latitude7, a.longitude7, a.latitude8, a.longitude8, a.latitude9, a.longitude9,
a.latitude10, a.longitude10, a.latitude11, a.longitude11
from materials a, users b
where a.status='1' and a.userid=b.id and add_date > $day)
$sql_cond");
while ($flGroup = mysql_fetch_row($quGroup)) {
$j++;
$a1 = $a2 = array ();
$l1 = $flGroup[0];
$l2 = $flGroup[1];
if ($l1 && $l2) {
$a1[] = $l1;
$a2[] = $l2;
}
$latitude2 = $flGroup[10];
$longitude2 = $flGroup[11];
if ($latitude2 && $longitude2) {
$a1[] = $latitude2;
$a2[] = $longitude2;
}
$latitude3 = $flGroup[12];
$longitude3 = $flGroup[13];
if ($latitude3 && $longitude3) {
$a1[] = $latitude3;
$a2[] = $longitude3;
}
$latitude4 = $flGroup[14];
$longitude4 = $flGroup[15];
if ($latitude4 && $longitude4) {
$a1[] = $latitude4;
$a2[] = $longitude4;
}
$latitude5 = $flGroup[16];
$longitude5 = $flGroup[17];
if ($latitude5 && $longitude5) {
$a1[] = $latitude5;
$a2[] = $longitude5;
}
$latitude6 = $flGroup[18];
$longitude6 = $flGroup[19];
if ($latitude6 && $longitude6) {
$a1[] = $latitude6;
$a2[] = $longitude6;
}
$latitude7 = $flGroup[20];
$longitude7 = $flGroup[21];
if ($latitude7 && $longitude7) {
$a1[] = $latitude7;
$a2[] = $longitude7;
}
$latitude8 = $flGroup[22];
$longitude8 = $flGroup[23];
if ($latitude8 && $longitude8) {
$a1[] = $latitude8;
$a2[] = $longitude8;
}
$latitude9 = $flGroup[24];
$longitude9 = $flGroup[25];
if ($latitude9 && $longitude9) {
$a1[] = $latitude9;
$a2[] = $longitude9;
}
$latitude10 = $flGroup[26];
$longitude10 = $flGroup[27];
if ($latitude10 && $longitude10) {
$a1[] = $latitude10;
$a2[] = $longitude10;
}
$latitude11 = $flGroup[28];
$longitude11 = $flGroup[29];
if ($latitude11 && $longitude11) {
$a1[] = $latitude11;
$a2[] = $longitude11;
}
if (!$l1 && !$l2 && !$latitude2 && !$longitude2 && !$latitude3 && !$longitude3 && !$latitude4 && !$longitude4 && !$latitude5 && !$longitude5 && !$latitude6 && !$longitude6 && !$latitude7 && !$longitude7 && !$latitude8 && !$longitude8 && !$latitude9 && !$longitude9 && !$latitude10 && !$longitude10 && !$latitude11 && !$longitude11)
continue;
...
}
как изящно
+130
int print_entry(const char* name, const char* dir,const struct stat* st)
{
if(!S_ISDIR(st->st_mode)){
if(S_ISREG(st->st_mode)){
printf("<file type=\"regular file\" owner=\"%d\" group=\"%d\">%s/%s</file>\n",st->st_uid,st->st_gid,dir,name);
};
if(S_ISCHR(st->st_mode)){
printf("<file type=\"charcter device\" owner=\"%d\" group=\"%d\">%s/%s</file>\n",st->st_uid,st->st_gid,dir,name);
}
if(S_ISBLK(st->st_mode)){
printf("<file type=\"block device\" owner=\"%d\" group=\"%d\">%s/%s</file>\n",st->st_uid,st->st_gid,dir,name);
}
if(S_ISFIFO(st->st_mode)){
printf("<file type=\"FIFO(named pipe)\" owner=\"%d\" group=\"%d\">%s/%s</file>\n",st->st_uid,st->st_gid,dir,name);
}
if(S_ISLNK(st->st_mode)){
char *linkname;
ssize_t r;
char *lname=strcat(dir,"");
linkname = new char[st->st_size + 1];
if (linkname == NULL) {
fprintf(stderr, "insufficient memory\n");
exit(EXIT_FAILURE);
}
r=readlink(lname, linkname, st->st_size + 1);
if (r < 0) {
return 0;
}
if (r > st->st_size) {
fprintf(stderr, "symlink increased in size "
"between lstat() and readlink()\n");
exit(EXIT_FAILURE);
}
linkname[st->st_size] = '\0';
printf("<file type=\"symbolic link\" owner=\"%d\" group=\"%d\" linkname=\"%s\">%s/%s</file>\n",st->st_uid,st->st_gid,linkname,dir,name);
}
if(S_ISSOCK(st->st_mode)){
printf("<file type=\"socket\" owner=\"%d\" group=\"%d\">%s/%s</file>\n",st->st_uid,st->st_gid,dir,name);
}
}
return 0;
}
int main(int argc, char* argv[])
{
if(argc != 2)
{
fprintf(stderr, "Usage: %s DIR\n", argv[0]);
exit(1);
}
printf("<dir name=\"%s\">\n",argv[1]);
walk(argv[1], print_entry, 1,0);
printf("</dir>",argv[1]);
}
Создание xml файла всех директорий, поддиректорий и их файлов