This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ant clean && ant | |
Buildfile: build.xml | |
clean: | |
BUILD SUCCESSFUL | |
Total time: 0 seconds | |
Buildfile: build.xml | |
init: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: &default_settings | |
database: APPNAME_development | |
host: 127.0.0.1 | |
port: 27017 | |
test: | |
<<: *default_settings | |
database: APPNAME_test | |
production: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App < Sinatra::Base | |
def initialize(url = '/some/url') | |
@url = url | |
end | |
get "#{@url}/?" do | |
# Doesn't match the URL. | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run me with: | |
# | |
# $ watchr specs.watchr.rb | |
# -------------------------------------------------- | |
# Convenience Methods | |
# -------------------------------------------------- | |
def all_test_files | |
Dir['test/**/*_test.rb'] - ['test/test_helper.rb'] | |
end |