Random line of code thread
category: code [glöplog]
Code:
$shorturl = file_get_contents("http://71nk.com/api/?url=$urlencode");
From http://71nk.com/l072b0
int x;
int y;
int summ;
summ=x+y;
print summ;
int y;
int summ;
summ=x+y;
print summ;
Code:
char *szFragment =
"float t=dot(gl_Color.xyz,vec3(1,256,65536)*11),r;vec2 o=vec2(gl_FragCoord)"
",c=vec2(512+sin(t*.01)*512,388)-o,e=c;void main(){int w=int(t+(o.x+o.y*512"
")*33);e.x-=2*sin(t*.01)*512;r=(16512+512*sin(t*.5))/dot(c,c)+16512/(e.x*e."
"x);r=r>2?(sin(o.x*o.y)-normalize(e).x)/r:r*.3;gl_FragColor+=r*.3+o.y*.001*"
"vec4(.2,.2,.05,1)+(w*w*w&0xFFFFFFF)*.0000000005+(int((o.x+o.y)*.01)&1)*.02"
";}";
Btw Ferris, every code can be written as a single line of code. Thus anything goes! :P
apparently pouet fucked it up... but oh well, it's the shader from this
some may not know it:
(with some tweaks, it sounds smooth, too ;))
Code:
/* smoothstep*/
float t = 0.1;
t = (t*t) * (3.0f - 2.0f * t);
float a = 0;
float b = 1;
return (a * (1.0f -t)) + (b * t);
(with some tweaks, it sounds smooth, too ;))
@Decipher: Preprocessor?? :P
macaw, why the urlencode?
Quote:
Btw Ferris, every code can be written as a single line of code. Thus anything goes! :P
Except python!
python -c 'exec("while True:\n\tprint \"LiraNuna is not right!\"")'
skrebbbbbel, to encode the url? :)
Code:
float zinv(float z)
{
//return (zFar*zNear / (zFar - z*(zFar-zNear)) - zNear) / (zFar - zNear);
//return zFar*zNear / (zFar - z*(zFar - zNear));
//return (-(1.0/zNear - 1.0/z) / (1.0/zNear - 1.0/zFar) - zNear) / (zFar - zNear);
//return 0.0; //(z - zNear)/(zFar - zNear);
return 1.0-(zNear*zFar/(zFar - z*(zFar-zNear))-zNear)/(zFar-zNear);
}
\mfx_utmw\glsl\depth.fs :)
Code:
template <typename R, typename A1, typename A2, typename A3, typename A4> inline SignalSlot4<R,A1,A2,A3,A4>* Signal4<R,A1,A2,A3,A4>::connect(typename GlobalSlot4<R,A1,A2,A3,A4>::Function function) { return connect(new GlobalSlot4<R,A1,A2,A3,A4>(function)); }
Here's my random number generator. It's lousy, it's not been tested in all situations, but somehow it seems to work ok. ;)
ARM code
68000 code
ARM rules!
Hi MrHill ;)
ARM code
Code:
REM Creates a new random number in m0, affects flags
DEFFNrandom(m0):[opt opt%:rsb m0,m0,m0,ror#11:]
68000 code
Code:
;IN \1.l=random number
;OUT \1.l=new random number
; \2.l killed
RANDOM MACRO
move.l \1,\2
ror.l #7,\1
ror.l #4,\1
sub.l \2,\1
ENDM
ARM rules!
Hi MrHill ;)
baah: it's incorrectly documented, though. RSB doesn't affect flags - RSBS does. ;)
@moose: Yup, sorry... My previous version was 2 instructions long and used an S version... I knew i shouldn't put comments! ;)
baah: Wrong comments are worse than no comments ;)
Well, here's my standard random number generator. It too is crap, wastes too many cycles, is system dependant etc etc (still it's faster than the system routine ;)). I use it mostly for precalcs though so I don't mind!
Code:
move.l $466.w,d2
rol.l #8,d2
add.l seed(pc),d2
sub.b $ffff8209.w,d2
move.l d2,seed
well, they have an obvious error in their code
see if you can spot it..
Code:
$longurl = "http://science.slashdot.org/article.pl?sid=09/04/21/045243";
$longurl = urlencode($longurl);
$shorturl = file_get_contents("http://71nk.com/api/?url=$urlencode");
echo $shorturl;
see if you can spot it..
Code:
$shorturl = file_get_contents("http://71nk.com/api/?url=$longurl");
macaw, but isn't it rediculous to urlencode an URL? i mean, i'm quite sure that the URL standard allows for all URL characters to appear in an URL. if there would be illegal characters in there, it wouldn't be a valid URL to begin with, so it wouldn't work, right? i.e. why not just http://71nk.com/api/?http://bla.com/~tuut/crap_banana and read $_SERVER['QUERY_STRING']?
but yeah, i'm nitpicking. now go make a jsonp interface!
but yeah, i'm nitpicking. now go make a jsonp interface!
Code:
uniform sampler2D RandTex; // <- 32x32 full noisy texture
vec4 Rand(const in vec2 p)
{
return texture2D(RandTex, p);
}
float PerlinNoise(in vec2 p)
{
float color = 0.0;
color += 0.5000000*Rand(p*0.5).r;
color += 0.2500000*Rand(p*1.0).r;
color += 0.1250000*Rand(p*2.0).r;
color += 0.0625000*Rand(p*4.0).r;
color += 0.0312500*Rand(p*8.0).r;
color += 0.0156250*Rand(p*16.0).r;
return color;
}
void main()
{
gl_FragColor = PerlinNoise(gl_TexCoord[0].xy*0.1);
}
JMP 0xFE
Code:
return $this->htmlRender->renderFormElement(
array(
'element' => 'text',
'name' => 'attr_'.$attr['attr_id'],
'class' => '',
'label' => $attr['label'],
'id' => 'attr_'.$attr['attr_id']
)
);
heres my 68k "random" number generator:
[code] ror.l d7,d7
addq #$b00b,d7
[code] ror.l d7,d7
addq #$b00b,d7
[/code] fail
addq fail
.w fail
=> fail generator \o/
addq fail
.w fail
=> fail generator \o/