- 1
- 2
echo( TRUE ? "1" : TRUE ? "2":"3");
//2
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+75
echo( TRUE ? "1" : TRUE ? "2":"3");
//2
http://ideone.com/UBg3T2
В ответ на это:
http://govnokod.ru/12268#comment163978
−100
(lambda x:request.profile.role if request.profile.role!=5 else 4)(request.profile.role)
+141
#include <stdio.h>
#include <conio.h>
#include <windows.h>
int main()
{
nachalo: system("cls");
int a;
printf("Write first number...");
scanf("%i", &a);
int b;
printf("Write second number...");
scanf("%i", &b);
int res1;
res1=a+b;
int res2;
res2=a-b;
int res3;
res3=a*b;
float res4;
res4=(float)a/b;
int res5;
res5=a*a;
int res6;
res6=b*b;
printf("\nSumm of %i + %i = %i\n", a, b, res1);
printf("Difference of %i - %i = %i\n", a, b, res2);
printf("Production of %i * %i = %i\n", a, b, res3);
printf("Private of %i / %i = %.4f\n\n", a, b, res4);
printf("Square of %i is %i\n", a, res5);
printf("Square of %i is %i\n\n", b, res6);
int max;
max = (b>a) ? b:a;
printf("The greatest number of %i and %i is %d\n\n", a, b, max);
int choice;
printf("To run program again, press number 1, else numbers \nor symbols will close the program...\n> ");
scanf("%i", &choice);
if (choice == 1)
{
goto nachalo;
}
else (choice != 1);
{
return 0;
}
}
Калькулятор. Nuff said
+50
<?php
session_start();
if(empty($_SESSION['UserLogin']) or empty($_SESSION['UserId']))
{
header('Location: /');
}
else
{
include("application/db.config.php");
$GetterUser = $_POST['ForUser'];
$SenderUser = $_SESSION['UserId'];
$Rem = strip_tags($_POST['Rem']);
$Text = strip_tags($_POST['Text']);
if($Rem == "" or $Text == "")
{
header("Location: sent_mess?to=$GetterUser&status=bad");
}
else
{
$SendingMessQuery = mysql_query("INSERT INTO Dialogs(From, To, Rem, Text) VALUES($SenderUser, $GetterUser, '$Rem', '$Text')", $db) or die(mysql_error());
mysql_close($db);
header("Location: sent_mess?to=$GetterUser&status=good");
}
}
...
−161
CREATE TABLE calendar
(
caldate date NOT NULL,
"month" integer NOT NULL,
month_txt character varying(10) NOT NULL,
"year" integer NOT NULL,
CONSTRAINT calendar_pkey PRIMARY KEY (caldate)
)
CREATE TABLE holiday
(
id numeric(10,0) NOT NULL DEFAULT nextval('holiday_seq'::regclass),
caldate date NOT NULL,
region integer,
CONSTRAINT holidaypk PRIMARY KEY (id),
CONSTRAINT fk_hday_caldate FOREIGN KEY (caldate)
REFERENCES calendar (caldate) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT holidayfk FOREIGN KEY (region)
REFERENCES region (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
Вот такая вот структура база в проекте в котором я работаю.
Причём помимо таблицы calendar и дублирование там информации, обратите внимание на таблицу holiday в эту таблицу записи ручками вносятся о выходных днях или о праздниках, как впрочем и в таблицу calendar
+163
jQuery("body").trigger( F11 )
Попытка перейти в полноэкранный режим.. Найдено в недрах одного довольно серьезного проекта.
+141
if(is_dir('install')|| is_dir('migrate')) {
if (!file_exists(PATH.'/includes/config.inc.php')){
header('location:/install/');
die();
} else {
include(PATH.'/core/messages/installation.html');
die();
}
}
+15
LambdaVar<1> X;
LambdaVar<2> Y;
// The next line prints 10:
cout << lambda(X,Y)[ plus[ multiplies[3,X], Y ] ] (3,1) << endl;
cout << lambda(X,Y)[ (3 %multiplies% X) %plus% Y ] << endl;
//...
lambda(X)[ X %plus% getCurrentTime[_*_] ]
//...
let[ X == someLambdaExp,
Y == someOtherLambdaExpWhichMayInvolveX ]
.in[ someLambdaExpInvolvingXandY ]
//...
lambda(X)[
letrec[ F == lambda(Y)[ if1[ Y %equals% 0,
1,
Y %multiplies% F[Y %minus% 1] ] ] ]
.in[ F[X] ] ]
//...
Maybe<int> mx = just(2);
Maybe<int> my = just(3);
mx = lambda()[ compM<MaybeM>()[ plus[X,Y] | X<=mx, Y<=my, guard[false] ] ]();
cout << mx << endl; // Nothing
//...
compM<ListM>()[ makePair[X,Y] | X<=list_with(1,2), guard[true],
Y<=list_with(3,4), guard[ (Y %divides% X) %equal% 3 ] ] ]
Грибки отсюда:
http://people.cs.umass.edu/~yannis/fc++/
+18
/*
* The use of singletons for globals makes globals not
* actually be initialized until it is first needed, this
* makes the library faster to load, and have a smaller
* memory footprint
*/
#define json_global_decl(TYPE, NAME, VALUE) \
class jsonSingleton ## NAME { \
public: \
inline static TYPE & getValue() json_nothrow { \
static jsonSingleton ## NAME single; \
return single.val; \
} \
protected: \
inline jsonSingleton ## NAME() json_nothrow : val(VALUE) {} \
TYPE val; \
}
#define json_global(NAME) jsonSingleton ## NAME::getValue() \
json_global_decl(json_string, CONST_TRUE, JSON_TEXT("true"));
json_global_decl(json_string, CONST_FALSE, JSON_TEXT("false"));
json_global_decl(json_string, CONST_NULL, JSON_TEXT("null"));
/* Использование */
json_global(ERROR_NULL_IN_CHILDREN)
Наткнулся на утечку памяти, отловленную Valgrind'ом
А внутри вот это. И главное, совершенно непонятно, зачем воротить эту свистопляску, если линкеры умеют распознавать "true" по всюду (читаем про ROMability тут: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2002/n1396.pdf )
http://stackoverflow.com/questions/690176/c-c-optimization-of-pointers-to-string-constants
Сам код отсюда: http://code.google.com/p/wot-replay-parser/source/browse/libjson/Source/JSONGlobals.h
−85
by :: Int -> [a] -> [[a]]
by _ [] = []
by n xs = take n xs: by n (drop n xs)
words2 :: String -> (String, String)
words2 str = conc $ words str where
conc (x:xs) = (x, concat xs)
groupTemplates :: String -> [(String, String)]
groupTemplates xs = map (words2) (lines xs)
decodeOne :: String -> [(String, String)] -> String
decodeOne _ [] = ""
decodeOne str (x:xs) | str == fst x = fst x ++ " " ++ snd x ++ "\n"
decodeOne str (_:xs) = decodeOne str xs
decode :: [String] -> [(String, String)] -> String
decode bs ts = concat $ map (\b -> decodeOne b ts) bs
main = do
bits <- readFile "bits.txt"
templates <- readFile "templates.txt"
writeFile "out.txt" $ decode (by 4 bits) (groupTemplates templates)
http://www.cyberforum.ru/haskell/thread723767.html