Skip to content

Instantly share code, notes, and snippets.

@plugnburn
plugnburn / game.js
Last active June 14, 2016 09:02
Arc Escape: Super Hexagon for the very poor, see complete compressed game at http://arc-escape.surge.sh
function T() {
var track = 'w=t>>9,k=32,m=2048,a=1-((t/m)%1),d=(((14*t*t)^t)%m)*a,y=([3,3,4.7,2][p=w/k&3])*(t/4),h=((("IQNNNN!!]]!Q!IW]WQNN??!!W]WQNNN?".charCodeAt(w/2&15|p/3<<4))/33)*t)-t,s=y*.98%80+y%80+(w>>7&&a*((5*t%m*a&128)*(0x53232323>>w/4&1)+(d&127)*(0xa444c444>>w/4&1)*1.5+(d*w&1)+(h%k+h*1.99%k+h*.49%k+h*.97%k-64)*(4-(2*a)))),(s*s>>14?127:s)+128',
duration = 120,
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+"))"))}
return beat(track, duration)
}
!function() {
var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || window.mozRequestAnimationFrame,
aud, screenHeight = 0, screenWidth = 0, minSide = 0, maxSide = 0, centerX = 0, centerY = 0, realLoop = null, score = 0, baseSpeed = 0, speed = 0,
@plugnburn
plugnburn / indexer.sh
Last active April 22, 2018 16:11
Catalite: Sqlite3-based text indexing and local search engine proof-of-concept in Bash
#!/bin/bash
# Catalite Indexer
# Adds new files or directories into the catalog database
# Usage: indexer.sh [db] [file|directory]
DB=''
openDb() {
DB="$*"
}
@plugnburn
plugnburn / dclock.sh
Created April 30, 2016 19:40
DClock: statusbar widget for DWM
#!/bin/bash
while true; do
loadAvg=$(cat /proc/loadavg | cut -d ' ' -f -4)
timeStr=$(date '+%a %b %d %H:%M:%S')
memAvail=$(grep -Po 'MemAvailable.*\d+' /proc/meminfo|cut -d ':' -f 2)
memTotal=$(grep -Po 'MemTotal.*\d+' /proc/meminfo|cut -d ':' -f 2)
memBusy=$(( $memTotal - $memAvail ))
xsetroot -name "RAM: $(( 100 * memBusy / memTotal ))% | CPU: $loadAvg | $timeStr"
sleep 1
done
@plugnburn
plugnburn / stego.js
Created March 29, 2016 19:38
PNG steganography in less than a kilo minified
//PNG steganography utils
//ratio: about 2 pixels per 1 byte of text message
//Auto EOD byte as 255
//Use only non-transparent images as the algo has to modify alpha-channel of affected pixels
//to protect RGB values from in-browser rounding
+function(w) {
var bitMapping = [0, 1, 2, 4, 5, 6, 8, 9], img = new Image(), cnv = document.createElement('canvas'), ctx=cnv.getContext('2d')
w.Stego = {
hide: function(imglink, msg, cb) { //image data URI (not only PNG) and message as input, resulting PNG image data URI as output (to callback)

ESVer: conditionally load your scripts depending on the target platform

ESVer is a tiny and convenient helper script to get you out of the overhead hell for the browsers that don't really need it. It detects whether a browser supports ES6/ES2015 standard natively and allows you to load different script versions depending on the result of this check.

Usage

Include your scripts like this:

@plugnburn
plugnburn / README.md
Last active January 31, 2023 15:02
DaBi - live two-way DOM-to-data binding in 25 lines of JS

DaBi: data binding library that keeps it simple

DaBi (short for Data Binding) is a dead simple yet complete and self-contained DOM-to-JS and JS-to-DOM data binding library in just 25 lines of pure ES5 and 454 bytes when minified.

How to obtain

Download it right here or include it into your HTML:

@plugnburn
plugnburn / README.md
Last active July 7, 2016 19:45
Z5: a nano-library bundle for client-side development

Z5

Move all your frontend development to real programming with Z5 nano-library bundle that contains:

  • Zen.js (v2) for reactive in-memory storage;
  • Q.js for DOM manipulation;
  • R.js for client-side routing;
  • XT.js for dynamic DOM construction/templating;
  • XS.js for dynamic stylesheet construction.
@plugnburn
plugnburn / README.md
Last active October 16, 2016 03:23
XS.js - an ultra-small CSS rule builder in 10 lines of JS

XS.js

This is an ultra-small library for dynamic CSS rules construction (accompanying DOM construction library XT.js). 244 bytes minified, under 200 bytes gzipped.

How to obtain

Download it here or include it into your HTML:

@plugnburn
plugnburn / README.md
Last active March 27, 2016 16:09
Psto: a single package.json to scaffold and run your single-post web page in no time

Psto

This is a no-brainer to get your single-post web page up and running. Just have to have Node and NPM installed, and /bin/sh pointing to Bash shell. Styling is powered by 999.css.

Steps:

  1. Place the below package.json into an empty directory and enter this directory in your command line prompt.
  2. Run npm run scaffold.
  3. Edit domain, title and author in the config section of your package.json. The domain may be either a Surge subdomain or your own (please refer to the Surge docs). If you're going to host your page yourself, you may leave domain empty.
@plugnburn
plugnburn / 999.css
Last active March 16, 2017 00:05
999.css - a 999-byte barebones CSS framework
*{box-sizing:border-box;outline:none}
html {font-size:17px;font-family:Roboto,arial,sans-serif}
code,pre{
font-size:0.9rem;font-family:"Droid Sans Mono",monospace;
word-wrap:break-word;
}
body {margin:0;padding:0;font-size:1rem;line-height:1.375}
body,th,td,input,textarea,select,option,h1,h2,h3,h4,.fbox,.fr,.fr>*{
font-size-adjust:0.5;
font-family:inherit;