- 1
jQuery("body").trigger( F11 )
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+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
+53
$this->_requestUri = 0 === strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])
? substr(
$_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])
)
: $_SERVER['REQUEST_URI'];
+102
var usr = Enumerable.Range(1, 1)
.Select(id => new User(1, "FooBar", "desc" + 1, DateTime.UtcNow))
.ToReadonly()
.GetRandomElement();
Из юнит-теста. Копипаста рождает чудовищ.
+25
public OnPlayerSpawn(playerid) {
IsSpawned[playerid]=1;
if(Team[playerid]==ZOMBIE) { TextDrawSetString(Textdraw9[playerid],"You are a ~r~Zombie~w~. Kill & Infect every Human to complete your mission.");
} else if(Team[playerid]==HUMAN) { TextDrawSetString(Textdraw9[playerid],"You are a ~r~Human~w~. Prevent Zombie attacks and survive till the end."); }
TextDrawHideForAll(Box); TextDrawHideForAll(text_Top5[0]); TextDrawHideForAll(text_Top5[1]);
TextDrawShowForPlayer(playerid, Textdraw0); TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw2); TextDrawShowForPlayer(playerid, Textdraw3);
TextDrawShowForPlayer(playerid, Textdraw4); TextDrawShowForPlayer(playerid, Textdraw5);
TextDrawShowForPlayer(playerid, Textdraw6); TextDrawShowForPlayer(playerid, Textdraw7);
TextDrawShowForPlayer(playerid, Textdraw9[playerid]);
TextDrawShowForPlayer(playerid, Textdraw15); TextDrawShowForPlayer(playerid, Textdraw16[playerid]);
SetTeam(playerid); SetClass(playerid);
if(Infection==1) {
Infection=0;
if(Totalplayers>=2) {
SetTimer("InfectionLoad",0,0);
} else if(Totalplayers>=10) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=10) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=20) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=30) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=45) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers>=60) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}else if(Totalplayers<=75) {
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
SetTimer("InfectionLoad",0,0);
}
} return 1; }
Серьезно?
−90
public static function findNeighbourEmpty(cx:int, cy:int, checkDebris:Boolean = true):Cell {
var cell:Cell = Cell.getCell(cx, cy);
var i:int = 0;
var distance:int = 1;
var n:int = 8;
while(!cell || !cell.accessible || (checkDebris && !isEmptyTile(cell))) {
if (i < n * distance / 4) {
cell = Cell.getCell(cx + Math.min(i, distance), cy + Math.min(distance * 2 - i, distance));
} else if (i < n * distance / 2) {
cell = Cell.getCell(cx + Math.min(distance * 2 - i + n * distance / 4, distance), cy + Math.max(n * distance / 4 - i, -distance));
} else if (i < 3 * n * distance / 4) {
cell = Cell.getCell(cx + Math.max(n * distance / 2 - i, -distance), cy + Math.max(-distance * 2 + i - n * distance / 2, -distance));
} else if (i < n * distance) {
cell = Cell.getCell(cx + Math.max(-distance * 2 + i - 3 * n * distance / 4, -distance), cy + Math.min(i - 3 * n * distance / 4, distance));
} else {
i = 0;
distance++;
if (distance > MAX_NEIGHBOUR_CELL_DISTANCE) {
return findNeighbourEmpty(cx, cy, false);
}
continue;
}
i++;
}
return cell;
}
Какой милый метод...
+140
Здравствуйте, господа!
Кто знает, как выяснить свободный порт виртуальной машины средствами PHP?