Skip to content

Instantly share code, notes, and snippets.

@Jontyy
Jontyy / debounce.js
Created December 15, 2011 22:22
JavaScript Debounce Function
//usage: http://jsbin.com/ucucuc
var debounce = function(delay,callback){
var timeout;
//$().keyup(debounce()) will be this function, it still has access to timeout because of closure
return function(){
var that = this,args = arguments,
delayed = function(){
callback.apply(that, args);
timeout = null;
//jQuery.reduce.js - https://github.com/jontyy - MIT licensed
jQuery.reduce = function(arr, func, initial){
initial = typeof initial === 'undefined' ? 0 : initial;
for(var i in arr){if(arr.hasOwnProperty(i) && !isNaN(parseInt(i,10))){
initial = func(initial,arr[i],i);
}}
return initial;
};
@Jontyy
Jontyy / Gruntfile.js
Last active December 17, 2015 21:49
Grunt JSHint Options
module.exports = function(grunt) {
"use strict";
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.initConfig({
// JSHint Configuration
// http://www.jshint.com/docs/
//
// All of the options can be placed in a .jshintrc, update options : { jshintrc : ".jshintrc" }
@Jontyy
Jontyy / CallbackQueue.js
Last active December 20, 2015 00:08
Tiny utility for queueing callbacks and ensuring they are executed one at a time and in order
var CallbackQueue = (function(){
var Worker = function(queue){
this.queue = queue;
this.working = false;
};
Worker.prototype.done = function(){
this.working = false;
this.work();
};
Worker.prototype.work = function(){

Keybase proof

I hereby claim:

  • I am jontyy on github.
  • I am jontyy (https://keybase.io/jontyy) on keybase.
  • I have a public key whose fingerprint is E95A 98A4 DB2F EE78 8D62 D59E 60AB 7D74 2FD0 3754

To claim this, I am signing this object: