Skip to content

Instantly share code, notes, and snippets.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
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
@PaulMaynard
PaulMaynard / output.html
Created December 16, 2013 03:11
Html tag template in mustache
<!doctype html>
<a href="/">link</a>
<img src="/img.png">
<div contenteditable></div>
@PaulMaynard
PaulMaynard / Imagesize.js
Last active August 29, 2015 13:57
Checks the size of all images on page to ensure they are the same as the dimensions of the image file
[].slice.call(document.getElementsByTagName('img')).map(function(i) {
var src = i.src, i2 = new Image();
i2.src = src
return {
src: src,
i1: i,
i2: i2
}
}).filter(function(i) {
return !(i.i1.width === i.i2.width || i.i1.height === i.i2.height)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
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
@PaulMaynard
PaulMaynard / index.js
Created June 8, 2014 22:44
Gist from mistakes.io
function roll(die) {
var result = 0, a = /(\d+)d(\d+)(?:([\+\-\*\/])(\d+))?/.exec(die);
var times = a[1], sides = a[2], op = a[3], mod = +a[4];
result = roll.raw(times, sides);
if(op && mod) result = roll.ops[op.replace(/x/g, '*')](result, mod);
return result
}
roll.raw = function(times, sides, total) {
total = total || 0;
total += Math.ceil(Math.random() * sides);
@PaulMaynard
PaulMaynard / index.js
Created June 9, 2014 17:13
Gist from mistakes.io
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.dist = function dist(p) {
return Math.sqrt(Math.pow(Math.abs(this.x - p.x), 2)
+ Math.pow(Math.abs(this.y - p.y), 2));
}
Point.prototype.toString = function() {
return '(' + this.x + ',' + this.y + ')'
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
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
@PaulMaynard
PaulMaynard / dabblet.css
Created June 18, 2014 20:35
OLQOS Home page
/**
* OLQOS Home page
*/
* {
box-sizing: border-box
}
body, html, #container {
height: 100%;
@PaulMaynard
PaulMaynard / MapProxy.js
Created October 18, 2014 16:08
ES6 Map Accessor Proxy
/**
* Proxy for accessing ES6 Maps like objects.
* Usage example:
*
* var p = new MapProxy();
* p['key'] = 'value';
* if ('key' in p) {
* console.log(p.key);
* }
* delete p.key;
@PaulMaynard
PaulMaynard / die.js
Last active May 2, 2016 16:13
Generator and Iterator manipulation
/** Sample die roller */
function die(pattern) {
let [, sign = '+', amt = 1, sides = 6, num, mod] = die.regex.exec(pattern)
let gen
if (num) {
gen = _.fill(Number(num))
} else {
let die = _.func(() => Math.floor(Math.random() * sides) + 1)
gen = _.combine(sum, ...Array(amt).fill(die))
}