Skip to content

Instantly share code, notes, and snippets.

function queue() {
queue.stack = queue.stack || [];
var push = function(scope, obj) { Array.prototype.push.call(scope, obj); }
if (arguments.length) {
queue.stack.push(arguments);
if (queue.process) return false;
}
@nhunzaker
nhunzaker / fibonacci.js
Created June 4, 2012 13:43
Ridiculous Fibonacci Calculator
function fib (step) {
fib.times = fib.times || 0;
fib.times += step || 1;
clearTimeout(fib.calculate);
fib.calculate = setTimeout(function() {
var first = 0,
@nhunzaker
nhunzaker / gist:2830256
Created May 29, 2012 19:42
My FED Pre-Commit Hook
#!/usr/bin/env ruby
errors = false
# Create a simple line break
puts ""
# Now let's get a list of the changed files that have been staged
changed_files = `git diff --staged --name-only HEAD`.split("\n")
$("button").click(function(){
 $("#container").load('demo_ajax_load.txt #container');
});
@nhunzaker
nhunzaker / config.ru
Created April 17, 2012 19:36
Well formated Wordpress with Compass
# Compass Configuration File
http_path = "/"
css_dir = "."
sass_dir = "sass"
images_dir = "img"
javascripts_dir = "js"
output_style = :compressed
line_comments = false
@nhunzaker
nhunzaker / gist:2322595
Created April 6, 2012 20:07
Resize and Crop Thumbnails with Image Magick
mogrify -thumbnail x400 -resize '400x<' -resize 50% -gravity center -crop 200x200+0+0 +repage -format jpg -quality 91 *.JPG
// Just a nice feature, returns another selector in the absence of
// a current one
jQuery.fn.or = function(s) {
return $(this).length? $(this) : $(s);
};
// Example:
$(".current").or("ul.gallery li:first-child").fadeIn();
var request = require('request'),
yahoo = require("../config/yahoo_key.json"),
qs = require('querystring');
function placefinder(string, callback) {
var base = "http://where.yahooapis.com/geocode?",
data = qs.stringify({
q : escape(string),
appid : yahoo.appid,
@nhunzaker
nhunzaker / microtest.js
Created March 23, 2012 20:03
A super simple self-tested testing framework for javascript
// Implementation
// -------------------------------------------------- //
function assert(condition, opt_message) {
'use strict';
if (!condition) {
var msg = 'Assertion failed';
if (opt_message) {
msg = msg + ': ' + opt_message;
@nhunzaker
nhunzaker / spree_variant_options.rb
Created March 12, 2012 15:11
Precompiling Assets for Spree Variant Options Plugin
require 'spree_core'
require 'spree_sample' unless Rails.env == 'production'
# All of the magic happens at the line "if Rails.version >= 3.1 ... "
# found in spree_variant_options/lib/spree_variant_options.rb
module SpreeVariantOptions
class Engine < Rails::Engine