Skip to content

Instantly share code, notes, and snippets.

View isaacsanders's full-sized avatar

Isaac Sanders isaacsanders

View GitHub Profile
Resetting...
Resetting stock for product 22 to 104 units.
(1 row(s) affected)
Removing order (OrderID=11077, ProductID=22).
(1 row(s) affected)
Adding order to Order Details table for 50 units of product 22.
(1 row(s) affected)
ruby_version = ask("What ruby version is your app?")
ruby_gemset = ask("What do you want to name your gemset?")
file(".ruby-version", ruby_version)
file(".ruby-gemset", ruby_gemset)
gem 'haml-rails'
gem 'bootstrap-sass'
@isaacsanders
isaacsanders / emacs-clojure.md
Last active August 29, 2015 14:23
Emacs Clojure Commands

CIDER Commands

C-c +

  • M-j: Jack into an nREPL session and open a REPL buffer.
  • M-n: Switch REPL to the current buffer's namespace.
  • C-z: Open REPL and move cursor to REPL.
  • C-o: Clear the last line's output.
  • M-o: Clear all the output
@isaacsanders
isaacsanders / subclass_include.rb
Last active August 29, 2015 14:23
Ruby Subclassing and Including
module Foo
def self.included base
puts "Included by #{base}"
end
end
class Bar
include Foo
def self.inherited(base)
@isaacsanders
isaacsanders / gist:1107078
Created July 26, 2011 15:53
Tim's Methods
require 'rspec'
require 'date'
describe "Tim's Methods:" do
let(:tim) { TimAffinity.new }
context "Tim is in India and" do
it "should be clear that Tim needs to get his ass back here" do
tim.do_we_want_him_back?.should be_true
@isaacsanders
isaacsanders / constant_class.rb
Created August 25, 2011 14:15
Keeping it Classy
# Foo is a constant that
Foo = Class.new
# We can define a superclass as an argument of the Class#new method,
# but the default is Object, and we are fine with that.
#=> Foo
Foo.class_eval do
def bar
:baz
end
@isaacsanders
isaacsanders / nested_def.rb
Created August 25, 2011 14:51
Def within a def
class Example
def foo
def foo
:every_other_call
end
:first_call
end
end
@isaacsanders
isaacsanders / reuse_user.rb
Created October 1, 2011 20:55
This is how you give your models easy role and action permissions.
require 'reuse'
class User
include ReUser
roles do
role(:admin) {|r| r.actions(:read, :write, :execute)}
role(:user) {|r| r.action(:read)}
default :user
end
@isaacsanders
isaacsanders / User.rb
Created October 2, 2011 03:21
For Jon Hogue
class User
include ReUser
roles do
role :god do |r|
r.action :manage_all
r.aciton :new_user_session
r.action :create_user_session
r.action :destroy_user_session
end
@isaacsanders
isaacsanders / List.rb
Created October 2, 2011 03:45 — forked from hoguej/User.rb
For Jon Hogue
roles do
role :admin, [:read, :write, :execute]
role :user do |r|
action :read
end
end