Skip to content

Instantly share code, notes, and snippets.

View trshafer's full-sized avatar

Thomas Shafer trshafer

View GitHub Profile
@trshafer
trshafer / AddClassMapping.coffee
Created November 20, 2013 23:44
back to coffee for rendr
ModelUtils = require('../../shared/modelUtils')
module.exports = class AddClassMapping
constructor: (@utils)->
@utils ||= new ModelUtils
add: (key, modelConstructor)=>
@utils._classMap[@utils.underscorize(key)] = modelConstructor;
@trshafer
trshafer / example.html
Created October 25, 2013 20:01
facebook-button.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.min.css" rel="stylesheet">
<style type="text/css">
.btn-facebook{
padding: 0px;
overflow: hidden;
@trshafer
trshafer / benchmark.js
Created October 18, 2013 00:23
Benchmark for model store checking params
var BaseModel, ModelStore, modelUtils, _;
ModelStore = require('../shared/store/model_store');
BaseModel = require('../shared/base/model');
modelUtils = require('../shared/modelUtils');
_ = require('underscore');
util = require('util');
@trshafer
trshafer / pre-commit
Created August 9, 2013 22:04
pre-commit
#!/usr/bin/env ruby
# do not check in code with <<<<< nor debugger
diff_contents = `git diff --cached --unified=0 --diff-filter=AM -z HEAD`
bad_commit_text = diff_contents =~ /^\+(<{3,}|(\s*|.*;\s*)debugger)/
abort "Aborting: Found debugger or <<< in commit diff." if bad_commit_text
# looks for text in reminders.txt
reminder_location = 'ignored/reminders.txt'
file_location = File.join( File.dirname(__FILE__), '..', '..', reminder_location)
@trshafer
trshafer / post-commit
Created August 9, 2013 22:03
post-commit
#!/bin/sh
[[ -d $(dirname $0)/../rebase-merge ]] || lolcommits --capture
@trshafer
trshafer / Gemfile
Created February 17, 2013 04:40
TDD Bus implementation with Keith
gem 'rspec'
gem 'debugger'
RSpec::Matchers.define :have_body_text do |text|
match do |mail|
fail("No body content to check for #{text}") if mail.parts.blank?
assert_mail_text_in_all_parts(mail, text)
end
def assert_mail_text_in_all_parts(mail, text)
mail.parts.all? do |part|
part.body.include?(text)
@trshafer
trshafer / load_blank_modules.rb
Created November 10, 2012 01:20
Load Blank Modules when const missing
# pretty much copied from active_support
module ModuleConstMissing
def self.append_features(base)
base.class_eval do
# Emulate #exclude via an ivar
return if defined?(@_const_missing) && @_const_missing
@_const_missing = instance_method(:const_missing)
remove_method(:const_missing)
end
super
@trshafer
trshafer / demo.html
Created November 9, 2012 01:43
Center column filling the height of either the left or right sides
<html>
<head>
<title>Middle height</title>
<style type="text/css">
/*Positioning CSS*/
.container{
overflow: hidden;
position: relative;
@trshafer
trshafer / humanized_seconds.rb
Created July 23, 2012 19:05
Humanized Seconds
def humanized_seconds secs
[[60, :second], [60, :minute], [24, :hour], [1000, :day]].map{ |count, name|
name = name.to_s
if secs > 0
secs, n = secs.divmod(count)
pluralized_name = n == 1 ? name : name.pluralize
"#{n.to_i} #{pluralized_name}"
end
}.compact.reverse.join(' ')
end