Skip to content

Instantly share code, notes, and snippets.

View dperrymorrow's full-sized avatar
💭
🍕

David Morrow dperrymorrow

💭
🍕
View GitHub Profile
@dperrymorrow
dperrymorrow / backbone_paginate.coffee
Created May 24, 2012 16:37
Backbone Pagination helper
Backbone.Helpers ||= {}
class Backbone.Helpers.Paginate extends dpm.Callbacks
# we simply store a ref to the instance and the property so that we dont have to store the data in two places, ! too big
constructor:(inst,prop,@perPage)->
super()
@setSource inst, prop
@reset()
reset:()->
@dperrymorrow
dperrymorrow / .git
Created June 14, 2012 23:17
git commit hooks
$ cat .git/hooks/pre-commit
#!/bin/sh
DIFF=`git diff HEAD`+`git diff --cached HEAD`
if [[ "$DIFF" == *"DO NOT COMMIT"* ]]
then
echo "Error; Attempt to commit a delta including the phrase 'DO NOT COMMIT'";
echo
echo "Use --no-verify to bypass this check."
@dperrymorrow
dperrymorrow / mymethodTest.js
Created June 22, 2012 19:12 — forked from gigasquid/mymethodTest.js
Example Spec File for Ajax Mocking with Jasmine
describe("Mocking Ajax Calls", function() {
beforeEach(function() {
loadFixtures('test.html');
//mocking ajax call with Jasmine Spies
var fakeData = "You can put your return data here";
spyOn($, "ajax").andCallFake(function(params) {
params.success(fakeData);
});
});
@dperrymorrow
dperrymorrow / switcher.js
Created July 13, 2012 19:01
switch out your stylesheets
$("*[rel='stylesheet']").each(function() {
var href = $(this).attr("href");
$(this).attr("href", "http://localhost:3000" + href);
});
@dperrymorrow
dperrymorrow / pre-commit.sh
Created September 10, 2012 16:18 — forked from intjonathan/pre-commit.sh
pre-commit hook (add to .git/hooks/pre-commit) to refuse to commit debugger strings
#!/bin/sh
# Refuse to commit files with the string NOCOMMIT, debugger, or merge markers present.
#
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-)
if [ "$files" != "" ]
then
for f in $files
do
@dperrymorrow
dperrymorrow / Custom.css
Created October 31, 2012 17:34 — forked from bentruyman/Custom.css
Tomorrow Theme for Chrome Developer Tools
/**********************************************/
/*
/* Tomorrow Skin by Ben Truyman - 2011
/*
/* Based on Chris Kempson's Tomorrow Theme:
/* https://github.com/ChrisKempson/Tomorrow-Theme
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@dperrymorrow
dperrymorrow / gist:5052553
Created February 27, 2013 22:45
Format your Rails stack trace into something you can read
document.getElementsByTagName('pre')[0].innerHTML = document.getElementsByTagName('pre')[0].innerHTML.replace(/,/g, ",\n").replace(/{/g, "{\n").replace(/}/g, "\n}")
@dperrymorrow
dperrymorrow / twilight mod.xml
Last active December 14, 2015 22:18
my mod of twilight to have red highlight for sublime linter, and also be softer on the eyes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Michael Sheets</string>
<key>name</key>
<string>Twilight</string>
<key>settings</key>
<array>
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@dperrymorrow
dperrymorrow / inheritance.js
Last active December 20, 2015 17:09
javascript inheritance
function Animal (name) {
console.log("Animal constructor is called " + name);
}
Animal.prototype.sleep = function () {
console.log(this.name + ' is sleeping');
};
// extending the parent classe