Skip to content

Instantly share code, notes, and snippets.

View danmcclain's full-sized avatar

Dan McClain danmcclain

View GitHub Profile
RSpec.configure do |config|
# == Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :mocha
if user.counselor? #checks role field
can :update, Student, school_id: user.school_id # says if the student's school_id is equal to the user's school id
end
{{#each array}}
{{view ItemView controlerBinding="controller"}}
{{/each}}
:javascript
$(function(){
$("#years").selectorize(Openbay.Vehicles)
});
%h2 {:id => 'currentSelection'}
.vehicle-picker
#years{:data => {:next => "makes", :order => "reverse"}}
%h2.year
require 'spec_helper'
describe EmailTemplate do
it { should have_valid(:category).when('Something') }
it { should_not have_valid(:category).when(nil,'') }
it { should have_valid(:content).when('Some content') }
it { should_not have_valid(:content).when(nil,'') }
it { should have_valid(:subject).when('Some subject') }
it { should_not have_valid(:subject).when(nil,'') }
@user = User.new(:email => 'test@example.com', :name => 'John Wayne')
string = "hello there {{user.email}} how are you {{user.name}}"
string.gsub(/\{\{(.+?)\}\}/) do |s|
eval("@#{$1}")
end
@danmcclain
danmcclain / pair.md
Created April 10, 2012 16:25 — forked from wm/pair.md
TMUX Pairing

SSH setup for remote pairing

If Animal and Fozzie wanted to pair on Animals machine and they both have access to shared.muppets.com then they could use the following setup

  • Animal will have the following in ~/.ssh/config
Host tunnel_from_muppets
  Hostname space.muppets.com
 RemoteForward 1235 localhost:22
@danmcclain
danmcclain / hack.sh
Created April 17, 2012 23:39 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@danmcclain
danmcclain / sample.rb
Created September 13, 2012 17:15
ARel issue
irb(main):001:0> a = Condition.arel_table
=> #<Arel::Table:0x007fefbc868e28 @name="conditions", @engine=ActiveRecord::Base, @columns=nil, @aliases=[], @table_alias=nil, @primary_key=nil>
irb(main):002:0> Arel::Nodes::Equality.new('1', Arel::Nodes::NamedFunction.new('ANY', a[:name])).to_sql
=> "'1' = ANY(\"conditions\", 'name')"
# Named function should produce ANY(\"conditions\".\"name\")
compat.version=1.9