Skip to content

Instantly share code, notes, and snippets.

@plugnburn
plugnburn / zw.js
Last active August 29, 2015 14:05
Zero-Width encoder/decoder with autodetection feature in 400 bytes
ZW={enc:function(s){return unescape(encodeURIComponent(s)).split("").map(function(c){return("00000000"+c.charCodeAt(0).toString(2)).substr(-8)}).join("").replace(/0/g,"\u200b").replace(/1/g,"\u200c")},dec:function(s){return(s=s.match(/[\u200b\u200c]{8}/g))&&decodeURIComponent(escape(s.map(function(c){return String.fromCharCode(parseInt(c.replace(/\u200b/g,0).replace(/\u200c/g,1),2))}).join("")))}}
@plugnburn
plugnburn / README.md
Last active August 29, 2015 14:04
DualWarp - a universal bootloader for data:URIs and external scripts to be usable in redirectable URLs

Overview

DualWarp is a simple 134-byte bootloader for URIs and external scripts. It was created for users who want their data: URIs and external script to be allowed for shortening and cloaked execution. You just host this single HTML file and then pass whatever you want (data: URI or external Javascript link) into the URL hash.

Usage

Note that when you call external script, it may be served as any MIME-type, so hacks like [Giffer] (https://gist.github.com/plugnburn/3364bc56ecc820534143) will also work when your JS is embedded into a GIF and uploaded to an image hosting.

@plugnburn
plugnburn / giffer.sh
Created July 10, 2014 19:37
Giffer - seamlessly embed JS into a GIF image to be usable both in <script> and <img> tags
#!/bin/bash
#Usage: giffer.sh input.gif input.js output.gif
(echo -n "GIF89a=/*";tail -c +10 $1;echo -n "*/0;$(<$2);")>$3
@plugnburn
plugnburn / README.md
Last active September 8, 2022 18:43
Micromark engine

Micromark: probably the smallest JS framework to create your own text markup languages

Overview

Have you ever dreamed of creating your own simple text markup language without all the overhead of existing parsers? Now it is possible thanks to this tiny function. Define your own rules for substituting your own character tags with HTML markup and pass them to Micromark along with your text, and it will return ready HTML code.

How to use the engine

Call the function like this:

@plugnburn
plugnburn / democode.js
Last active December 25, 2015 19:09
Some democode routines (will be updated from time to time)
//bytebeat: beat(pattern,length)
beat=function(b,e,a,t){return(a="data")+":audio/wav;base64,UklGRl9fX19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgA"+btoa(eval("for(t=0;++t<e*8e3;)a+=String.fromCharCode(255&("+b+"))"))}
//bytebeat with math: beatm(pattern,length)
beatm=function(b,e,a,t){return(a="data")+":audio/wav;base64,UklGRl9fX19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgA"+btoa(eval("with(Math)for(t=0;++t<e*8e3;)a+=String.fromCharCode(255&("+b+"))"))}
//konamicode: konami(callback)
konami=function(k,c){onkeyup=function(e){/113302022928$/.test(c+=[e.which-37])&&k()}}
//circle gesture detection: circgest(callback[, clockwiseflag])
//clockwiseflag: 1 - counterclockwise, 0 or absent - clockwise
circgest=function(f,a,v,i,c,o){c=v="";addEventListener("mousemove",function(e){o&&(i=2*(e.screenX>o.screenX)+(e.screenY>o.screenY),i^c&&(v+=i,c=i),(a?/3201$/:/2310$/).test(v)&&(f(),v=""));o=e},0)}
@plugnburn
plugnburn / index.html
Created October 3, 2013 17:41
Pong999 - adaptive multiplayer pong in 999 bytes. Controls: A/Z keys for player 1, Up/Down arrows for player 2. Play at http://bl.ocks.org/plugnburn/raw/6813874/
<!DOCTYPE html><title>Pong</title><body onload='R=window.requestAnimationFrame||function(c){setTimeout(c,16)};Z=document.querySelector("canvas"),p=s=0;(onresize=function(){H=(K=Z.height=innerHeight)/5,W=(J=Z.width=innerWidth)>>6,M=W>>1})();(D=function(){Y=Z.getContext("2d"),Y.font="40pt monospace",Y.textBaseline="top",O=P=(K-H)>>1,x=M+W+1,y=O+(H-W)>>1,U=I=0,B=V=4})();onkeydown=function(e){eval({65:"U=-4",90:"U=4",38:"I=-4",40:"I=4"}[e.which])};onkeyup=function(e){eval({65:"U",90:"U",38:"I",40:"I"}[e.which]+"=0")};R(Q=function(){R(Q);with(Math)A=abs,O=min(max(O+U,M),z=K-M-H),P=min(max(P+I,M),z);(y<M||y>K-M-W)&&(B=-B);x<=M+W&&(y+W>=O&&y<=O+H?V=A(U)-V:D(++s)),x>=J-M-W-W&&(y+W>=P&&y<=P+H?V=-V-A(I):D(++p));Y.F=Y.fillRect;with(Y)fillStyle="#000",F(0,0,J,K),fillStyle="#eee",F((J-W)/2,0,W,K),F(M,O,W,H),F(J-W-M,P,W,H),F(x+=V,y+=B,W,W),textAlign="right",fillText(p,J/2-W-M,M),textAlign="left",fillText(s,J/2+W+M,M)})'><canvas style=position:fixed;top:0;left:0>Use a browser, moron!</canvas></body>
@plugnburn
plugnburn / LICENSE.txt
Last active December 21, 2015 21:08 — forked from 140bytes/LICENSE.txt
Downloader.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 plugnburn
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@plugnburn
plugnburn / LICENSE.txt
Last active January 8, 2022 19:40 — forked from 140bytes/LICENSE.txt
Linear Feedback Shift Register implementation
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 plugnburn
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@plugnburn
plugnburn / bitspace.js
Created August 12, 2013 07:56
BitSpace text steganography bookmarklet
//BitSpace bookmarklet
//Just add the below URL to your bookmark bar
//To hide the text into your input, focus on your input field and call the bookmarklet, then input the text to hide
//To reveal the text, select the text in non-input field and call the bookmarklet
javascript:(function(z){BitSpace=eval('({hide:Yh,i,d,e){d=(h=h.split("").map(Yn){Xn.charCodeAt(0).toString(2)Z[+c]}).join("")}).join(" ")).length;e=0;Xi.replace(/ /g,Y){Xe<d?h[e++]:" "})},reveal:Yr,v,l){if(r=r.match(/[ \\u2004\\u2008]/g)){for(v=0,l="";v<r.length;v++)l+=r[v];Xl.split(" ").map(Ys){XString.fromCharCode(parseInt(sZ.indexOf(c)}).join(""),2))}).join("")}}})'.replace(/Z/g,'.split("").map(Yc){X["\\u2004","\\u2008"]').replace(/Y/g,"function(").replace(/X/g,"return ")),z=document.activeElement;z.value?z.value=BitSpace.hide(prompt("Text to hide"),z.value):alert(BitSpace.reveal(getSelection()+""))})()
@plugnburn
plugnburn / LICENSE.txt
Last active December 20, 2015 15:29 — forked from 140bytes/LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 plugnburn
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE