Skip to content

Instantly share code, notes, and snippets.

View Oshuma's full-sized avatar

Dale Campbell Oshuma

  • @unite-us
  • Earth
View GitHub Profile
@Oshuma
Oshuma / rvm-prompt.zsh
Created October 11, 2009 01:31
rvm-prompt.zsh
# zsh functions to grab the current ruby version info from RVM.
# Useful mainly in prompts (see http://skitch.com/oshuma/nni3k/zsh-prompt-git-clean).
# ~/.zshrc
# RPS1=$'Ruby v$(ruby_prompt_version)'
# Ruby Version Manager
if [ -s ~/.rvm/scripts/rvm ] ; then
source ~/.rvm/scripts/rvm
@Oshuma
Oshuma / mac.zsh
Created October 11, 2009 01:58
mac.zsh
# ----------------------
# variables
# ----------------------
PATH="$PATH:/opt/local/bin:/opt/local/sbin:/usr/games:/usr/local/mysql/bin:/usr/local/sbin"
MANPATH="$MANPATH:/opt/local/man"
IRB_HISTORY_FILE=$HOME/.irb_history
LESS='-M -R -X'
# ----------------------
$ ./script/console
Loading development environment (Rails 2.1.1)
>> Rails.env
=> "test"
$ ./script/console development
Loading development environment (Rails 2.1.1)
>> Rails.env
=> "test"
$ macgem list
*** LOCAL GEMS ***
bacon (1.1.0)
httpattack-lib (0.2.1)
$ macirb
irb(main):001:0> require 'rubygems'
=> false
{
:Base => 'app_config/base',
:Error => 'app_config/error',
:Storage => 'app_config/storage'
}.each_pair { |name, file| autoload name, file }
@Oshuma
Oshuma / specs.watchr.rb
Created November 3, 2009 07:44 — forked from mynyml/specs.watchr.rb
specs.watchr.rb
# Run me with:
#
# $ watchr specs.watchr.rb
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_test_files
Dir['test/**/*_test.rb'] - ['test/test_helper.rb']
end
class App < Sinatra::Base
def initialize(url = '/some/url')
@url = url
end
get "#{@url}/?" do
# Doesn't match the URL.
end
end
@Oshuma
Oshuma / authentication.rb
Created November 20, 2009 17:47 — forked from jnunemaker/authentication.rb
mongo_auth
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
@Oshuma
Oshuma / database.yml
Created November 21, 2009 21:30 — forked from jnunemaker/database.yml
mongo_mapper + database.yml
development: &default_settings
database: APPNAME_development
host: 127.0.0.1
port: 27017
test:
<<: *default_settings
database: APPNAME_test
production:
curl "http://en.wikipedia.org/wiki/Pipeline_(Unix)" | \
sed 's/[^a-zA-Z ]/ /g' | \
tr 'A-Z ' 'a-z\n' | \
grep '[a-z]' | \
sort -u | \
comm -23 - /usr/share/dict/words | \
while read line; do
echo Not Found: $line
done