Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math| /** | |
| * Michael Scott Hertzberg <mshertzberg@gmail.com> (http://hertzber.gs) | |
| * | |
| * recursively check for set localStorage value every 100ms. | |
| * this will also safely clear the timeout once found. | |
| * can be used callback style or directly. | |
| * functionally pure. | |
| */ | |
| function waitForLocalStorage(key, cb, timer) { | |
| if (!localStorage.getItem(key)) return (timer = setTimeout(waitForLocalStorage.bind(null, key, cb), 100)) |
Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math| #!/bin/bash | |
| # git-cleanup-repo | |
| # | |
| # Author: Rob Miller <rob@bigfish.co.uk> | |
| # Adapted from the original by Yorick Sijsling | |
| git checkout master &> /dev/null | |
| # Make sure we're working with the most up-to-date version of master. | |
| git fetch |
| function keepTrying(otherArgs, promise) { | |
| promise = promise||new Promise(); | |
| // try doing the important thing | |
| if(success) { | |
| promise.resolve(result); | |
| } else { | |
| setTimeout(function() { | |
| keepTrying(otherArgs, promise); |