This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dec2hex (dec) { | |
hex = dec.toString(16); | |
if (hex.length < 2) { | |
hex = "0" + hex; | |
} | |
return hex; | |
} | |
function toLittleEndian (number, dontPad) { | |
var power = Math.floor((Math.log(number) / Math.LN2) / 8) * 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class $ | |
constructor: (query) -> | |
return document.querySelector(query) | |
@find: (parent, query) -> | |
parent.querySelector(query) | |
@findAll: (parent, query) -> | |
parent.querySelectorAll(query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Super simple templating engine | |
tmpl = (template, namespace) -> | |
fn = (existing, fieldName) -> | |
content = namespace[fieldName] | |
content ?= existing | |
return content | |
template.replace(/\{\{([a-z0-9_]*)\}\}/ig, fn) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var noble = require('noble'); | |
noble.on('stateChange', function (state) { | |
console.log('state:', state); | |
if (state === 'poweredOn') { | |
console.log('scanning...'); | |
noble.startScanning(); | |
} else { | |
noble.stopScanning(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MIN = 1; | |
var MAX = 3999; | |
var CHARS = 'IVXLCDM '; | |
function toRomanNumeral (input) { | |
if (input > MAX || input < MIN) { | |
throw new Error('Cannot convert number'); | |
} | |
var offset = CHARS.length - 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function exportLocalStorage () { | |
var output = {}; | |
for (var key in localStorage) { | |
if (!localStorage.hasOwnProperty(key)) { | |
continue; | |
} | |
output[key] = localStorage[key]; | |
} | |
return JSON.stringify(output).replace(/'/g, '\\\'').replace(/"/g, '\\"'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -iname '*.js' -not -path "*/__tests__/*" -exec wc -l {} \; | ag -o \\d+ | paste -sd+ - | bc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var successPromise = new Promise(function (resolve, reject) { | |
setTimeout(resolve, 1000); | |
}); | |
successPromise.then(function () { console.log('this should succeed') }); | |
var failingPromise = new Promise(function (resolve, reject) { | |
setTimeout(reject, 1000); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# img2vid | |
# ======= | |
# | |
# Convert an image into three second video | |
# | |
# Usage: ./img2vid photo.jpg video.mp4 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snap | audience | |
---|---|---|
0 | 100 | |
1 | 95 | |
2 | 82 | |
3 | 78 | |
4 | 61 | |
5 | 59 | |
6 | 42 | |
7 | 30 | |
8 | 29 |
OlderNewer