Skip to content

Instantly share code, notes, and snippets.

View dtao's full-sized avatar

Dan Tao dtao

View GitHub Profile
@dtao
dtao / throttle.js
Created May 17, 2012 20:17
Function to throttle a callback so that it only executes after a specified amount of time has elapsed since the last invocation
function throttle(callback, delay, before) {
var busy = false;
var hold = false;
function callAfterDelay(self, args) {
setTimeout(function() {
if (hold) {
hold = false;
callAfterDelay(self, args);
return;
@dtao
dtao / userChrome.css
Created April 17, 2012 16:59
Custom userChrome.css file to increase the font size in Thunderbird's thread tree
#threadTree treechildren {
font-size: 16pt;
}
#threadTree treechildren:-moz-tree-row {
border-bottom: 1px solid #E1E1E1;
height: 20pt !important;
}
@dtao
dtao / eachAsync.js
Created April 10, 2012 14:52
Function to asynchronously iterate over a collection
function eachAsync(collection, iterator, callback) {
var iterate = function(i) {
setTimeout(function() {
iterator(collection[i]);
if (i < collection.length) {
iterate(i + 1);
} else {
callback();
}
}, 0);