- 1
+++++[>++>+++[>+++>+++<<-]>+<<<-]+++[>>>-.<[>>.>+<<+.<-]<.>>+.>>+[<.<-.<+>>>-]<<+<+<.<-]
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+143
+++++[>++>+++[>+++>+++<<-]>+<<<-]+++[>>>-.<[>>.>+<<+.<-]<.>>+.>>+[<.<-.<+>>>-]<<+<+<.<-]
Brainfuck, задача - вывести
1
2-1
1-2-3
4-3-2-1
1-2-3-4-5
6-5-4-3-2-1
Из этой ветки: http://habrahabr.ru/post/116842/#comment_3794462
+141
...
else if ( (!BG_InSpecialJump( legsAnim )//not in a special jump anim
||BG_InReboundJump( legsAnim )//we're already in a rebound
||BG_InBackFlip( legsAnim ) )//a backflip (needed so you can jump off a wall behind you)
//&& pm->ps->velocity[2] <= 0
&& pm->ps->velocity[2] > -1200 //not falling down very fast
&& !(pm->ps->pm_flags&PMF_JUMP_HELD)//have to have released jump since last press
&& (pm->cmd.forwardmove||pm->cmd.rightmove)//pushing in a direction
//&& pm->ps->forceRageRecoveryTime < pm->cmd.serverTime //not in a force Rage recovery period
&& pm->ps->fd.forcePowerLevel[FP_LEVITATION] > FORCE_LEVEL_2//level 3 jump or better
//&& WP_ForcePowerAvailable( pm->gent, FP_LEVITATION, 10 )//have enough force power to do another one
&& BG_CanUseFPNow(pm->gametype, pm->ps, pm->cmd.serverTime, FP_LEVITATION)
&& (pm->ps->origin[2]-pm->ps->fd.forceJumpZStart) < (forceJumpHeightMax[FORCE_LEVEL_3]-(BG_ForceWallJumpStrength()/2.0f)) //can fit at least one more wall jump in (yes, using "magic numbers"... for now)
//&& (pm->ps->legsAnim == BOTH_JUMP1 || pm->ps->legsAnim == BOTH_INAIR1 ) )//not in a flip or spin or anything
)
{//see if we're pushing at a wall and jump off it if so
if ( allowWallGrabs )
{
//FIXME: make sure we have enough force power
//FIXME: check to see if we can go any higher
//FIXME: limit to a certain number of these in a row?
//FIXME: maybe don't require a ucmd direction, just check all 4?
//FIXME: should stick to the wall for a second, then push off...
...
Больше условий богу условий!
Jedi Academy source, 2003
+148
var attr_class = document.createAttribute("class");
attr_class.nodeValue="th_tr";
th.setAttributeNode(attr_class);
И нет, attr_class больше нигде не используется. Кто-то из наших сотрудников экспериментировал, похоже.
+13
Официальный тред для каклосрача
срать тут ↓
+81
procedure SetCurrentThreadName(const AName: String);
type
TThreadNameInfo = record
RecType: LongWord;
Name: PChar;
ThreadID: LongWord;
Flags: LongWord;
end;
var
LThreadNameInfo: TThreadNameInfo;
begin
with LThreadNameInfo do
begin
RecType := $1000;
Name := PChar(AName);
ThreadID := $FFFFFFFF; // -1 - текущий поток; также сюда можно вставить ID другого потока
Flags := 0;
end;
try
RaiseException($406D1388, 0, SizeOf(LThreadNameInfo) div SizeOf(LongWord),
PDWord(@LThreadNameInfo));
except
end;
end;
Попытка создать именованный поток.
Не хак. (http://msdn.microsoft.com/en-us/library/xcb2z8hs%28VS.71%29.aspx)
+140
@echo brutushafens, если ты есть вконтакте, добавь меня в друзья, поговорим. vk.com/cageo
@echo если тебя нет вконтакте, напиши мне на [email protected].
@pause
Послание для brutushafens :)
+84
{*********** PosEx ***********}
function Posex(const substr,str:string; const startloc:integer):integer;
{Search for "substr" in "str" starting at "startloc" return 0 or the start
postion where "substr" was found}
var
i, j,k,ssLen, sLen, stop:integer;
a:char;
begin
result:=0;
ssLen:=length(substr);
slen:=length(str);
stop:=slen-sslen+1; {highest feasible start location for substring}
if (ssLen=0) or (sslen>sLen) then exit;
a:=substr[1]; {1st letter of substr}
i:=startloc; {start search location}
while (i<=stop) and (result=0) do
begin
while (i<=stop) and (a<>str[i]) do inc(i); {find the 1st letter}
if i<=stop then
begin
if sslen=1 then result:=i {It was a 1 character search, so we're done}
else
begin
j:=2;
k:=i-1; {back "K" up by 1 so that we can use K+j as the index to the string}
while (j<=sslen) do
begin {compare the rest of the substring}
if (substr[j]<>str[k+j]) then break
else inc(j); {The letter matched, go to the next+
{When we pass the substring end, "while" loop will terminate}
end;
if (j>sslen) then
begin
result:=i;
exit;
end
else inc(i); {that search failed, look for the next 1st letter match}
end;
end;
end;
end;
Несколько вложенных циклов - это НЕ может работать быстро.
Для сравнения - функция PosEx из StrUtils.pas
function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
var
I,X: Integer;
Len, LenSubStr: Integer;
begin
if Offset = 1 then
Result := Pos(SubStr, S)
else
begin
I := Offset;
LenSubStr := Length(SubStr);
Len := Length(S) - LenSubStr + 1;
while I <= Len do
begin
if S[i] = SubStr[1] then
begin
X := 1;
while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do
Inc(X);
if (X = LenSubStr) then
begin
Result := I;
exit;
end;
end;
Inc(I);
end;
Result := 0;
end;
end;
The Delphi "Pos" function searches for a
substring within a string. Later versions of
Delphi also include a "PosEx" function
which
starts the search at a given position so
multiple calls can return all occurrences.
This program tests DFF versions of these
two
functions. Pos was rewritten to provide a
base
of code for PosEx. And PosEx wll provide
the
missing function for versions of Delphi
before
Delphi 7.
As an unexpected bonus, it appears that the
DFF versions of Pos and Posex are slightly
quicker than the D7 versions.
+141
@echo off
start https://pp.vk.me/c607724/v607724832/6c07/5fRLUPfqMe8.jpg
start https://pp.vk.me/c607724/v607724832/6c1c/LD7Zqx1yZAw.jpg
Для батника, запустите - поймёте ;)
+149
function rawToStructuredDataTree($data) {
$structured_array = array();
foreach ($data as $cid => $node) {
$data[$cid]['children'] = array();
if ($node['parent_id'] == $cid || $node['parent_id'] == 0) {
$structured_array[$cid] = &$data[$cid];
} else {
$data[$node['parent_id']]['children'][$cid] = & $data[$cid];
}
}
return $structured_array;
}
Вот такое выдал мой ученик (школьник, 8 класс), когда его попросили из массива id - parent_id построить дерево.
+143
// основная функция запуска
func main($script){
//устанавливаем значение переменной
$caption = "гыыы кальулятор";
//грузим иконку
$calc_icon= library_load_icon(library_load("shell32.dll"),307);
//создаем окошко))
$main_window=gui_window("TCalc",$caption,$_WS_SYSMENU+$_WS_VISIBLE+$_WS_CAPTION,$_CW_DESKTOPCENTER,$_CW_DESKTOPCENTER,200,100,$calc_icon,0,0,"WindowFunc");
gui_control($main_window,"button","ok",201,$_WS_CHILD+$_WS_VISIBLE+$_BS_DEFPUSHBUTTON+$_BS_FLAT,152,16,32,16);
gui_control($main_window,"edit","2+7",202,$_WS_CHILD+$_WS_VISIBLE,2,15,130,15);
gui_control($main_window,"static","Ready",203,$_WS_CHILD+$_WS_VISIBLE,16,36,130,16);
//иконка в трее...
tray_icon($main_window,$calc_icon,"ГАЛЬГУЛЯТОР",$_NIM_ADD);
tray_icon_show_balloon($main_window,"[$caption] -> Startup","Добро пожаловать в программу\nСоздано с неизвестным языком (название не придумал)",4);
idle(); //перевод программы в режим ожидания
}
func WindowFunc($hwnd,$msg,$param,$id){ //обработка сообщений виндоуса
if($msg==$_WM_CLOSE){ //если крестик нажали
tray_icon($main_window,$calc_icon,null,$_NIM_DELETE); //удаляем иконку
close(); //выходим
}
if($msg==$_WM_COMMAND){ //если нажали кнопку
if($id==201){ //click ok //определяем ID //math_compiler - производить математические операции
$res=math_compiler(gui_get($hwnd,202)); //gui_get - получить текст
if length($res)==0 { //gui_set - установить текст
$res="[ERROR]";
tray_icon_show_balloon($hwnd,"[$caption] -> Ашипка","Нивазможна\nправирить текст!",2);
}else{
tray_icon_show_balloon($hwnd,"[$caption] -> Result",gui_get($hwnd,202)." = $res",4);
}
gui_set($hwnd,203,$res);
}
}
}
Названия языка нет..
Если не нравятся названия команд (например, func и т.д.), то пишите, исправлю. Потом вам готовую версию вышлю :)