Skip to content

Instantly share code, notes, and snippets.

@simon-lang
simon-lang / unit testing with jsdom and jquery.coffee
Created May 20, 2013 23:50
unit testing with jsdom and jquery
should = require 'should'
mocha = require 'mocha'
jsdom = require 'jsdom'
global._ = require 'underscore'
global.window = jsdom.jsdom().createWindow() # Create a fake DOM/jQuery for testing UI components
global.document = window.document
global.$ = require('jquery').create(window) # WARNING: jQuery for testing is 1.8.3 - different to app
$.extend $.fn, fastClick: $.fn.click # extend jQuery with a faux fastClick method
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@arapehl
arapehl / gist:1114622
Created July 29, 2011 20:10 — forked from rgrove/gist:1114618
Using YUI group configs to combo handle custom modules
YUI({
groups: {
'my-group': {
comboBase: 'http://example.com/combo?',
combine : true,
root : 'build/',
modules: {
/* custom module definitions */
}