As configured in my dotfiles.
start new:
tmux
start new with session name:
function parse_git_branch { | |
[ -d .git ] || return 1 | |
git_status="$(git status 2> /dev/null)" | |
branch_pattern="^# On branch ([^${IFS}]*)" | |
remote_pattern="# Your branch is (.*) of" | |
diverge_pattern="# Your branch and (.*) have diverged" | |
if [[ ! ${git_status}} =~ "working directory clean" ]]; then | |
state="*" | |
fi | |
# add an else if or two here if you want to get more specific |
class ImportController << ApplicationController | |
require 'net/http' | |
require 'net/https' | |
require 'uri' | |
#THIS METHOD TO SEND USER TO THE GOOGLE AUTHENTICATION PAGE. | |
def authenticate | |
# initiate authentication w/ gmail | |
# create url with url-encoded params to initiate connection with contacts api |
def fib(n) | |
(0..n).inject([1,0]) { |(a,b), _| [b, a+b] }[0] | |
end |
## | |
# Use this behind the scenes to migrate files from your filesystem to Amazon S3 | |
# %: rake paperclip_migration:migrate_to_s3 | |
## | |
namespace :attachments do | |
desc "migrate files from filesystem to s3" | |
task :migrate_to_s3 => :environment do | |
require 'aws/s3' |
#config/initializers/redis.rb | |
require 'redis' | |
require 'redis/objects' | |
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys | |
dflt = REDIS_CONFIG[:default].symbolize_keys | |
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym] | |
$redis = Redis.new(cnfg) | |
Redis::Objects.redis = $redis |
As configured in my dotfiles.
start new:
tmux
start new with session name:
# Sample implementation of quicksort and mergesort in ruby | |
# Both algorithm sort in O(n * lg(n)) time | |
# Quicksort works inplace, where mergesort works in a new array | |
def quicksort(array, from=0, to=nil) | |
if to == nil | |
# Sort the whole array, by default | |
to = array.count - 1 | |
end |
package main | |
import ( | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"time" | |
) | |
type Person struct { |