Skip to content

Instantly share code, notes, and snippets.

View PDegenPortnoy's full-sized avatar
🏠
Working from home

Peter Degen-Portnoy PDegenPortnoy

🏠
Working from home
View GitHub Profile
@PDegenPortnoy
PDegenPortnoy / AASM_Callback_Fail
Created September 11, 2013 14:44
Acts As State Machine (AASM) with callback sample code that was initial, non-functioning, implementation
class Tester < ActiveRecord::Base
include AASM
aasm_initial_state :inactive
aasm_state :inactive
aasm_state :active,
:after_enter => :after_active_state
aasm_event :activate do
transitions :to => :active,
:from => [:inactive],
@PDegenPortnoy
PDegenPortnoy / StudentGradePrinter.rb
Last active December 22, 2015 06:29
Samples and examples of application framework for Launch Academy
# Sample ReportOutputter & child class (FileOutputter)
class ReportOutputter
attr_accessort :report_generator
def initialize(report_generator)
@report_generator = report_generator
end
def write
print_all_students
@PDegenPortnoy
PDegenPortnoy / gist:5699313
Created June 3, 2013 16:21
Code example for Ohloh blog on getting an OAuth request tocken
gem 'oauth'
require 'oauth/consumer'
@consumer = OAuth::Consumer.new("your api key", "your oauth consumer secret", :site => "http://www.ohloh.net")
@request_token = @consumer.get_request_token
@PDegenPortnoy
PDegenPortnoy / gist:4235914
Created December 7, 2012 19:42
Add color & git branch to your prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
PS1="$GREEN \w$YELLOW \$(parse_git_branch)\$ "