Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 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 / 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 / watchcoder.sh
Last active August 29, 2015 14:05
WatchCoder - encode any number from 0 to 5183999 to the values you can store in your Casio electronic watch, decode the stored values back into number
#!/bin/bash
# The WatchCoder method guarantees to encode an unsigned 22-bit (or signed 21-bit converted to unsigned)
# integer into the values present in any electronic Casio watch: an alarm setting and 1-hour stopwatch
# Maximal theoretically encodable unsigned value is 5183999
case "$1" in
num2watch)
[ -z "$2" ] && echo "Specify the number to encode" && exit 1
NUM=$2
SWDABS=$(($NUM / 1440))
ALMABS=$(($NUM % 1440))
@plugnburn
plugnburn / README.md
Last active August 29, 2015 14:06
SMSPP: Short Message Security

SMSPP: Short Message Security

Overview

SMSPP (stands for Short Message Security - Pencil and Paper) is a simple, pencil-and-paper based protocol to exchange very short encrypted messages via commonly available communication channels with a limited character set (such as SMS, hence the name).

SMSPP Workflow

@plugnburn
plugnburn / anonstrap.sh
Created November 2, 2014 15:40
AnonStrap - experimental anonymous posting engine using DualWarp-type loader, StrapdownJS renderer and TinyURL API
#!/bin/bash
#Usage: anonstrap.sh [your markdown file] ["optional title"]
LOADER="http://bl.ocks.org/anonymous/raw/f15ba2c3e3ea8742ced3/"
INMD="$1"
TITLE="$2"
[ -z "$TITLE" ] && TITLE="Anonymous post"
INPUT="$(<$INMD)"
HTML="<!DOCTYPE html><html><head><meta charset=utf-8><title>${TITLE}</title></head><xmp style='display:none'>${INPUT}"'</xmp><script src="http://strapdownjs.com/v/0.2/strapdown.js"></script></html>'
B64=$(echo -n "$HTML"|base64 -w 0)
DATAURL="data:text/html;charset=utf-8;base64,$B64"
@plugnburn
plugnburn / b312e-cheatbook.md
Last active April 3, 2023 17:34
Samsung B312E Cheatbook

B312E Cheatbook: pump up your Samsung Metro!

This is probably the most complete cheats and secret codes reference for the new Samsung SM-B312E phone you can ever find on the Internet. The main reason I say this is because most of the codes were dumped straight from the firmware (the European version, B312EXXNE6), others, meant for much older models, were also found on the Internet, but almost all of them were then tested on a real device (if the code is not tested, there's a note about this in the "Notes and warnings" column) and a description was made what do they do right here, on B312E. This cheatbook is divided into several parts: information codes, testing codes, setting codes, codes with undefined behavior and general tips and tricks.

Please note: GSM-related USSD codes (such as call divert, Caller ID display etc) are not included here because all of them are common for all GSM phones, their functionality is completely duplicated in standard call settin

@plugnburn
plugnburn / tweetgrid.css
Last active August 29, 2015 14:17
TweetGrid: a tweet-sized (137 bytes) fork of ungrid.css with pixel media limit, shorter class names and two helper classes for one-third and one-fourth layout cases
@media(min-width:481px){.gr{width:100%;display:table;table-layout:fixed}.gc{display:table-cell}.gc.f3{width:33.333333%}.gc.f4{width:25%}}