Skip to content

Instantly share code, notes, and snippets.

View Oshuma's full-sized avatar

Dale Campbell Oshuma

View GitHub Profile
function use_ruby() {
version=$1
if [ ! $version ]; then echo "Usage: $0 <version>"; return; fi
echo "Switching to Ruby v$version";
binaries=( erb gem irb rake rdoc ruby testrb )
for bin in $binaries; do
full_name="$bin$version"
full_path=`which $full_name`
@Oshuma
Oshuma / mongo_objects.py
Created February 19, 2010 07:28
Simple MongoDB wrapper that stores arbitrary objects using its class name as the key.
from pymongo import Connection
class MongoObjects:
def __init__(self, options = {}):
self.options = options
self.host = options.get('host', 'localhost')
self.port = options.get('port', 27017)
self.database = options.get('database', 'mongo_objects')
self.collection = options.get('collection', 'objects')
@Oshuma
Oshuma / Jabber-SH.rb
Created January 29, 2010 08:50 — forked from pcreux/Jabber-SH
#!/usr/bin/env ruby
# Jabber-SH — SH console via XMPP/Jabber (GTalk)
#
# Jabber-SH allows you to administrate a remote computer via a command line
# through a Jabber client. It’s like SSH via GoogleTalk! :)
# This is just a hack but it might be usefull sometime to run basic commands
# on a machine that is not accessible via ssh.
#
# Philippe Creux. pcreux/AT/gmail/DOT/com
$ ant clean && ant
Buildfile: build.xml
clean:
BUILD SUCCESSFUL
Total time: 0 seconds
Buildfile: build.xml
init:
We couldn’t find that file to show.
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
@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:
@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.
class App < Sinatra::Base
def initialize(url = '/some/url')
@url = url
end
get "#{@url}/?" do
# Doesn't match the URL.
end
end
@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