r/tinycode • u/Slackluster • Feb 21 '20
Game Hue Jumper is now open source! - A low fi endless runner that fits in a 2 kilobyte zip
r/tinycode • u/Slackluster • Feb 21 '20
r/tinycode • u/m-chrzan • Feb 08 '20
r/tinycode • u/Slackluster • Jan 18 '20
r/tinycode • u/Slackluster • Jan 15 '20
r/tinycode • u/adarshpunj • Jan 08 '20
I recently came across this project (StackOverFlow in 4k bytes), and it looked very interesting:
https://www.reddit.com/r/tinycode/comments/1yc0kv/st4koverflow_as_much_stack_overflow_as_possible/
I have tried to compress Instagram in a single HTML doc. You can explore profiles/hashtags, etc. The total file size is 4066 bytes.
r/tinycode • u/BenRayfield • Jan 06 '20
A symmetric crypto algorithm, on any number of bytes and any password size, bigO(number of bytes SQUARED), that uses sha256 on all bytes except the first to choose a byte to xor the first byte, then rotate by 1 byte and repeat until its rotated 2 times
I might make small adjustments to the algorithm, so dont count on it staying exactly the same yet. Still needs testing and use in blocks such as block size 56 is most efficient.
Testing class immutable.hashrotatecrypt.HashRotateCrypt
cryptMe: The quick brown fox jumps over the lazy dog
cryptMe to bytes then back to string: The quick brown fox jumps over the lazy dog
password: password
encryptedHex: 5a824f18a851c2b219a293bb8978176783ef339395f979f48dd1e00a144ba30db25b1696a1557603fb8ee8
encryptedString: Z�O��Q²�����x�g��3���y��� �K� �[���Uv����
DecryptedString: The quick brown fox jumps over the lazy dog
still experimental. The following is the main logic in https://github.com/benrayfield/hashrotatecrypt/blob/master/immutable/hashrotatecrypt/HashRotateCrypt.java
public static byte[] crypt(int cyclesPositiveOrNegative, byte[] cryptMe, byte[] symmetricPassword){
byte[] b = cryptMe.clone();
MessageDigest hasher = null;
try{
hasher = MessageDigest.getInstance("SHA-256");
}catch (NoSuchAlgorithmException e){ throw new Error(e); }
int cycles = b.length*2;
while(Math.abs(cyclesPositiveOrNegative) != 0){
//hash concat(b[1..end],symmetricPassword)
//and use 1 of those bytes to xor b[0], then rotate b by 1 byte.
boolean forward = cyclesPositiveOrNegative > 0;
if(!forward){ //rotate by 1 byte other direction
byte temp = b[b.length-1];
System.arraycopy(b, 0, b, 1, b.length-1);
b[0] = temp;
cyclesPositiveOrNegative++;
}
hasher.update(b, 1, b.length-1);
hasher.update(symmetricPassword);
byte[] hash = hasher.digest();
byte hashByte = hash[hash.length-1]; //TODO which is better, the start or the end of sha256?
b[0] ^= hashByte;
if(forward){ //rotate by 1 byte
byte temp = b[0];
System.arraycopy(b, 1, b, 0, b.length-1);
b[b.length-1] = temp;
cyclesPositiveOrNegative--;
}
if(cyclesPositiveOrNegative != 0) hasher.reset();
}
return b;
}r/tinycode • • Jan 01 '20
<body onload=setInterval("with(Math)H=hypot,U=cos,T=sin;for(s=_=>(0|c/32)&1?_/16&1:_/y%y,D.width=D.height=y=256,t=c++/9,z=y*y;z--;)i=0|z/y,b=z%y,_=s(H(i-T(t)*y,b-U(t/3)*y)^H(i-T(t/4)*4,b-U(t/2))),D.getContext`2d`.fillRect(i,b,_,_)",c=0)><canvas id=D>Screenshots: https://imgur.com/a/RGd2Igg/
By the way, if anyone could help me figure out how to capture canvas animations as gifs or whatever, I’d be much obliged. I’ve tried out the MediaRecorder API as well as some other libraries built for this kind of thing, but I always end up with just a bunch of black frames in the end, even if I explicitly set the canvas to a white background.
r/tinycode • u/Slackluster • Dec 30 '19
r/tinycode • • Dec 24 '19
<body onload=with(c)for(b=width=height=1024,z=b*b;z--;)getContext`2d`.fillRect(x=0|z/b,y=z%b,a=(x^y)/b,a)><canvas id=c>For the “4K” version, substitute 1024 with 4096, just be warned that it will probably take a couple of minutes to render! And of course, we could shave a couple of bytes off of this by sacrificing resolution, but a substitution of 4 is pretty underwhelming.
Edit:
Here’s the 1024x1024 version: https://i.imgur.com/r6ypAmO.jpg
Also:
4x4: https://i.imgur.com/kImmrRY.jpg
16x16: https://i.imgur.com/Q0MRSuC.jpg
64x64: https://i.imgur.com/jKSzi4y.jpg
256x256: https://i.imgur.com/PePvgDw.jpg
And 4096x4096: https://i.imgur.com/Oa6EblH.jpg
r/tinycode • u/Diapolo10 • Dec 23 '19
print("Pi:", sum(map(
lambda x, y: 4/x-4/y,
range(1, 10**6, 4),
range(3, 10**6, 4))))The accuracy is hard-coded as 10**6 (one million) because beyond that a single thread will be very slow, but it could be any number. And by using additional threads this could probably be multithreaded with three extra lines.
r/tinycode • u/LAK132 • Nov 30 '19
r/tinycode • u/nanochess • Nov 25 '19
r/tinycode • u/ajeet_dsouza • Nov 20 '19
r/tinycode • u/nakilon • Nov 19 '19
r/tinycode • u/nanochess • Nov 03 '19
r/tinycode • u/Slackluster • Nov 01 '19
r/tinycode • u/BenRayfield • Nov 01 '19
r/tinycode • u/CodePlea • Oct 31 '19
r/tinycode • u/Slackluster • Oct 31 '19
r/tinycode • u/rxi • Oct 31 '19