Skip to content

Instantly share code, notes, and snippets.

View dperrymorrow's full-sized avatar
💭
🍕

David Morrow dperrymorrow

💭
🍕
View GitHub Profile
<?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>
(function () {
"use strict";
window.utils = window.utils || {};
window.utils.ajaxFilters = {
initialize: function () {
$(document).ajaxError($.proxy(this, 'ajaxError'));
$(document).ajaxStart($.proxy(this, 'ajaxStart'));
$(document).ajaxComplete($.proxy(this, 'ajaxComplete'));
},
@dperrymorrow
dperrymorrow / jsbin.lugof.html
Last active August 29, 2015 14:01
Prototype extension with Javascript
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
@dperrymorrow
dperrymorrow / assets.rake
Last active August 29, 2015 14:02
asets rake file
require 'js-routes'
namespace :project do
namespace :assets do
desc "generate js routes in javascript"
task :js_routes => :environment do
JsRoutes.generate!("#{Rails.root}/public/javascripts/routes.js", exclude: [/.*admin.*/])
end
@dperrymorrow
dperrymorrow / application.rb
Created June 11, 2014 02:04
Rails generators to use RSpec and FactoryGirl
config.generators do |g|
g.test_framework(
:rspec,
{
:fixtures => true,
:view_specs => false,
:helper_specs => false,
:routing_specs => false,
:controller_specs => true,
:request_specs => true
@dperrymorrow
dperrymorrow / print.js
Created July 22, 2014 20:53
catching print requests with javascript
(function() {
var beforePrint = function() {
console.log('Functionality to run before printing.');
};
var afterPrint = function() {
console.log('Functionality to run after printing');
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
@dperrymorrow
dperrymorrow / kill mission.sh
Created September 25, 2014 23:40
kill zooming mission control
defaults write com.apple.dock expose-animation-duration -int 0
@dperrymorrow
dperrymorrow / percentage.sql
Last active August 29, 2015 14:11
Percentage query in MySQL
SELECT SUM((SELECT COUNT(*) FROM `posts` WHERE `approved` = 1) /
(SELECT COUNT(*) FROM `posts`) * 100) AS 'Percentage Approved'
@dperrymorrow
dperrymorrow / vars.js
Last active August 29, 2015 14:12
how to reference variables properly in Javascript
// there is no reason to ever do this. I think PHP folks do this
window["myVariable"];
// why not just do this
window.myVariable;
// save the first for when it's actually a variable
var foo = "someVarName";
window[foo];
@dperrymorrow
dperrymorrow / handlebars-helpers.js
Created June 18, 2015 19:42
Handlebars Helpers
(function () {
"use strict";
Handlebars.registerHelper('isSelected', function (optId, id) {
return optId === id ? 'selected="true"' : '';
});
Handlebars.registerHelper('classIf', function (val, className) {
return val ? className : '';
});