Skip to content

Instantly share code, notes, and snippets.

@atmin
atmin / rateLimit.js
Last active December 20, 2015 08:59
Execute given `func`tion no more often than once every `delay` milliseconds, queue all calls, do not drop anything (unlike throttle and debounce)
/*
** Execute given `func`tion no more often than once every `delay` milliseconds,
** queue all calls, do not drop anything (unlike throttle and debounce)
**
** Example usage:
** rateLimitedFunc = rateLimit(function (i) { console.log(i) }, 500)
** for (var i=0; i < 10; i++) rateLimitedFunc(i)
*/
function rateLimit(func, delay) {
var queue = [],
@atmin
atmin / fabfile.py
Last active December 16, 2015 08:08 — forked from ianpreston/fabfile.py
from fabric.api import local
import sys, os, webbrowser, jinja2
BASE_PATH = sys.path[0]
SRC_PATH = os.path.join(BASE_PATH, 'src')
BUILD_PATH = os.path.join(BASE_PATH, 'build')
JINJA_ENV = jinja2.Environment(loader=jinja2.FileSystemLoader(SRC_PATH))