Skip to content

Instantly share code, notes, and snippets.

View danheberden's full-sized avatar

Dan Heberden danheberden

View GitHub Profile
@danheberden
danheberden / mojax.js
Last active September 29, 2015 17:48
mock ajax for the jqueries
// Mojax
// Copyright (c) 2011 Dan Heberden
// Dual licensed under the MIT and GPL A
var randomStrings = [ "Joe", "Bill", "Steve", "Mark", "Joanne", "Megan", "Kristy", "Suzie" ];
$.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
if ( /^\/?mock-ajax/.test( originalOptions.url ) ) {
// make new deferred and save any success/error handlers
var dfd = new $.Deferred(),
success = options.success,
@danheberden
danheberden / gist:1726609
Created February 2, 2012 23:59
Simple Object Contructor With fn
// New Object Template
(function(){
var thing = window.Thing = function( a ) {
return new window.Thing.fn.init( a );
};
thing.fn = thing.prototype = {
constructor: thing,
init: function( a ){
// init the 'thing'
function s:setupWrapping()
set wrap
set wrapmargin=2
set textwidth=72
endfunction
" md, markdown, and mk are markdown and define buffer-local preview
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
@danheberden
danheberden / reuse_object.js
Created March 21, 2012 17:54
Reusable object pattern
/* This is an fn that can:
a) make new objects by itself or with the new keyword using some kind of identifier
b) return a cached object if an object with the same identifier is requested
c) is, itself, one of these objects
d) no id is a global ID
e.g.
var foo = new maker('baz');
var foo1 = maker('baz');
maker('baz') === foo; // true
maker('baz') === foo1; // true

gith

githOOKS - simple node server that responds to github post-receive events

Getting Started

Install the module with: npm install gith

// create a gith server on port 9001
var gith = require('gith').create( 9001 );

gith

githOOKS - simple node server that responds to github post-receive events

Getting Started

Install the module with: npm install gith

// create a gith server on port 9001
var gith = require('gith').create( 9001 );
LIB_DIR="/usr/local/lib/nave"
LIB_NAVE="$LIB_DIR/nave.sh"
BIN_NAVE="/usr/local/bin/nave"
ALIAS_NAVE="alias nave-update=\"cd /usr/local/lib/nave; git pull; cd > /dev/null 2>&1\""
echo "##########################################################################"
echo "Installing nave..."
echo "See http://github.com/isaacs/nave for more information"
echo ""
if [ -f "$LIB_NAVE" ]; then
@danheberden
danheberden / file-add-repo.js
Created September 18, 2012 16:07
Gith: File:add to repo example
var gith = require( 'gith' ).create( 9001 );
gith({
repo: 'danheberden/gith'
}).on( 'file:add', function( payload ) {
console.log( 'these files were added', payload.files.added );
});
@danheberden
danheberden / file-add-filtered.js
Created September 18, 2012 16:08
Gith: File:add of specific match to repo example
var gith = require( 'gith' ).create( 1337 );
gith({
repo: 'danheberden/gith',
file: /^test\/payloads/
}).on( 'file:add', function( payload ) {
/* files were added to /test/payloads in danheberden/gith */
});
@danheberden
danheberden / all.js
Created September 18, 2012 16:09
Gith: All actions example
var gith = require( 'gith' ).create( 9001 );
gith().on( 'all', function( payload ) {
/* update the website! */
});