Skip to content

Instantly share code, notes, and snippets.

View rubyist's full-sized avatar

Scott Barron rubyist

View GitHub Profile
scott@blah aproject[master*]$ gem --version
1.8.5
scott@baldyak aproject[master*]$ bundle exec spec spec/models/some_spec.rb
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Users/scott/.rvm/gems/ruby-1.8.7-p334@project/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Users/scott/.rvm/gems/ruby-1.8.7-p334@project/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /Users/scott/.rvm/gems/ruby-1.8.7-p334@project/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
1/2 c butter
1 1/4 lb grated sweet potato
2 1/2 T packed brown sugar
1/4 t salt
1/4 c tequila
juice of 2 limes
In a cast iron skillet:
* melt butter
* stir in sweet potatoes, pat into even layer
@rubyist
rubyist / gist:937435
Created April 22, 2011 19:43
rails cattr_reader
# File activesupport/lib/active_support/core_ext/class/attribute_accessors.rb, line 28
def cattr_reader(*syms)
options = syms.extract_options!
syms.each do |sym|
class_eval( unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym} @@#{sym} end, __FILE__, __LINE__ + 1)
unless options[:instance_reader] == false
class_eval( def #{sym} @@#{sym} end, __FILE__, __LINE__ + 1)
end
end
@rubyist
rubyist / new.html.erb
Created March 23, 2011 15:12
Thing Model
<% form_for Thing.new do |f| %>
<%= f.text_field :combined %>
<input type="submit" value="Create" />
<% end %>
@rubyist
rubyist / gist:744019
Created December 16, 2010 21:09
WAT?!
backtrace must be Array of String
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/message_expectation.rb:214:in `rescue in verify_messages_received'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/message_expectation.rb:209:in `verify_messages_received'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/proxy.rb:226:in `block in verify_expectations'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/proxy.rb:226:in `map'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/proxy.rb:226:in `verify_expectations'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/proxy.rb:79:in `verify'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/methods.rb:76:in `rspec_verify'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundler1/gems/rspec-1.3.1/lib/spec/mocks/space.rb:10:in `block in verify_all'
/Users/scott/.rvm/gems/ruby-1.9.2-p0@bundl
require 'test/unit'
module Stuff
def self.included(base)
base.extend Stuff::ClassMethods
end
module ClassMethods
def foo
'foo'
tell application "System Events"
tell current location of network preferences
set VPNservice to service "Name of VPN"
if exists VPNservice then disconnect VPNservice
end tell
end tell
alias iphone="open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app"
(defun rename-file-and-buffer (new-name)
(interactive "sNew Name: ")
(write-file (buffer-file-name))
(setq new-file-path (concat (file-name-directory (buffer-file-name)) new-name))
(if vc-mode
(vc-rename-file (buffer-file-name) new-file-path)
(rename-file (buffer-file-name) new-file-path))
(set-visited-file-name new-file-path nil 1))
on opening folder this_folder
tell application "Safari"
activate
tell application "System Events"
tell process "Safari"
click menu item "New Tab" of menu "File" of menu bar 1
end tell
end tell
set the URL of document 1 to "file:///Users/scott/Books/Foo/index.html"
end tell