Skip to content

Instantly share code, notes, and snippets.

@nathanhammond
nathanhammond / jquery.ancestry.js
Created August 13, 2008 15:18
Functionality to add a filter for descendants and ancestors of a jQuery set.
/*
Ancestry - jquery.ancestry.js
As discussed in the jQuery Development Google Group.
Released under the MIT license.
Involved: Michael Geary, Diego Perini, John-David Dalton, John Resig, and Nathan Hammond
Compiled: Nathan Hammond
*/
jQuery.comparePosition = function ( element, context) {
@nathanhammond
nathanhammond / jquery.subsection.js
Created August 13, 2008 15:27
Extension to jQuery to imitate the Form.elements array for any arbitrary descendant of a form.
/*
Serialize Subsection - jquery.subsection.js
Copyright (c) 2008 Nathan Hammond
Released under the MIT license.
With thanks to Michael Geary, Diego Perini, John-David Dalton, John Resig, and Garrett Smith for vetting elements of this idea.
Requires jQuery revision 5826 or later with the change to jQuery.fn.serializeArray() to query this.elements.
Requires Ancestry plugin.
*/
@nathanhammond
nathanhammond / jquery.textchange.js
Created August 27, 2010 15:38 — forked from mkelly12/jquery.textchange.js
Properly setup the event to account for initial content at the time of the first event binding. Reduce the delay to make it fire as quickly as possible. Remove two unused special events. Formatting.
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
@nathanhammond
nathanhammond / textareadiff.js
Created August 27, 2010 21:55
Simple textarea diff functionality.
/*
* Textarea Diff
* Simple textarea diff functionality.
*
* Copyright 2010, Nathan Hammond
* Released under the MIT License
*/
function diff(oldtext, newtext) {
// Only one difference. Guaranteed contiguous.
@nathanhammond
nathanhammond / wsbenchtest.js
Created October 26, 2010 20:33
Test case for interesting connection limit bug.
/*
To run test...
1. Get wsbench. Update the shebang in wsbench/wsbench if necessary.
> git clone git://github.com/pgriess/wsbench.git
> cd wsbench
2. Add in our test case by saving this file (wsbenchtest.js) into the wsbench directory.
3. Start the socket.io chat example.
@nathanhammond
nathanhammond / node_redis_commands.js
Created March 7, 2011 21:57
Simple script to get all Redis commands in a format that mranney/node_redis can use.
var http = require('http');
var fs = require('fs');
var redisio = http.createClient(80, 'redis.io');
function getCommands() {
var commandrequest = redisio.request('GET', '/commands.json', {'Host': 'redis.io'});
commandrequest.end();
var commandsfile = fs.createWriteStream('commands.json');
commandrequest.on('response', function (response) {
@nathanhammond
nathanhammond / $loader.js
Created April 7, 2011 22:13
$loader (pronounced "money-loader") is a simple script for using either the embedded version of jQuery or loading your own copy but saving a reference in your own scope. The primary use-case for this is in development of code that will be embedded into ot
// Load jQuery.
var $loader = function(callback) {
this.callback = callback;
this.check$();
}
$loader.prototype = {
// Check to see if we have our own copy of jQuery.
check$: function(version) {
// Load event version.
// TODO: Limit to our earliest supported version of jQuery.
@nathanhammond
nathanhammond / testcase.html
Created December 14, 2011 21:26
Simplified testcase for Ember bug.
<!doctype html>
<html lang="en">
<head>
<title>Ember Bug</title>
<script type="text/x-handlebars" data-template-name="president">
The President of the United States is {{name}}.
</script>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.7.1.js"></script>
@nathanhammond
nathanhammond / scroll.html
Created January 4, 2012 07:15
Simplified testcase for jQuery UI Draggable bugs.
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<style type="text/css">
html { overflow-y: scroll; }
.tile td { width: 20px; height: 20px; }
.tile td.full { background: red;}
.board { width: 800px; height: 800px; background: black; }
</style>
@nathanhammond
nathanhammond / Test Results.txt
Created March 1, 2012 04:31
EMCC Test Errors, OS X 10.6.8
======================================================================
ERROR: test_openjpeg (__main__.default)
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/runner.py", line 4744, in test_openjpeg
make_args=[]) # no -j 2, since parallel builds can fail
File "tests/runner.py", line 275, in get_library
copy_project=True)
File "/Users/nathanhammond/Repos/emscripten/tools/shared.py", line 450, in build_library
stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env)