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
body { | |
margin: 0; | |
font-family: Helvetica,sans-serif; | |
-webkit-font-smoothing: subpixel-antialiased; | |
} | |
#content { | |
margin: 20px auto; | |
} |
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
// source: https://www.sitepoint.com/cache-fetched-ajax-requests/ | |
const cachedFetch = (url, options) => { | |
let expiry = 5 * 60 // 5 min default | |
if (typeof options === 'number') { | |
expiry = options | |
options = undefined | |
} else if (typeof options === 'object') { | |
// I hope you didn't set it to 0 seconds | |
expiry = options.seconds || expiry |
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
const hashstr = s => { | |
let hash = 0; | |
if (s.length == 0) return hash; | |
for (let i = 0; i < s.length; i++) { | |
let char = s.charCodeAt(i); | |
hash = ((hash<<5)-hash)+char; | |
hash = hash & hash; // Convert to 32bit integer | |
} | |
return hash; | |
} |
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
import Dexie from 'dexie'; | |
class MyDerivedDexie extends Dexie { | |
anotherProperty; | |
anotherMethod() { | |
// Do something here... | |
} | |
constructor (name, options) { |
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
git archive --format=zip [email protected] master filepath > zip_name.zip |
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
FROM node:7.4 | |
ENV HEY_HOME /hey-node | |
RUN mkdir ${HEY_HOME}/ | |
WORKDIR $HEY_HOME | |
COPY package.json ${HEY_HOME}/ | |
RUN npm install |
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 asyncify(fn) { | |
var orig_fn = fn, | |
intv = setTimeout(function() { | |
intv = null | |
if (fn) fn() | |
}, 0) | |
fn = null | |
return function() { |
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 timeoutify(fn, delay) { | |
var intv = setTimeout(function() { | |
intv = null | |
fn(new Error("Timeout!")) | |
}, delay) | |
return function() { | |
if (intv) { | |
clearTimeout(intv) | |
fn.apply(this, arguments) |
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
Array.prototype.where = | |
function(f) | |
{ | |
var fn = f ; | |
// if type of parameter is string | |
if ( typeof f == "string" ) | |
// try to make it into a function | |
if ( ( fn = lambda( fn ) ) == null ) | |
// if fail, throw exception | |
throw "Syntax error in lambda string: " + f ; |
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 lambda( l ) { | |
var fn = l.match(/\((.*)\)\s*=>\s*(.*)/) ; | |
var p = [] ; | |
var b = "" ; | |
if ( fn.length > 0 ) fn.shift() ; | |
if ( fn.length > 0 ) b = fn.pop() ; | |
if ( fn.length > 0 ) p = fn.pop() | |
.replace(/^\s*|\s(?=\s)|\s*$|,/g, '').split(' ') ; | |
NewerOlder