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 ContainerLabel < ActiveRecord::Base | |
aasm_column :state | |
aasm_initial_state :undownloaded | |
aasm_state :undownloaded | |
aasm_state :downloaded | |
aasm_event :download do | |
transitions :to => :downloaded, :from => :undownloaded | |
end | |
def download |
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
def nav_item(title, url) | |
active_class = current_path?(url) ? ' class=\'active\'' : '' | |
content = '<li' + active_class + '>' | |
content << capture do | |
link_to title, url | |
end | |
content << content_tag(:span) << '</li>' | |
content.html_safe | |
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
named_scope :patient_first_name_or_last_name_or_mrn_like, lambda{|name| | |
Patient.first_name_or_last_name_or_mrn_like(name).proxy_options.merge({:joins =>[{:order => :patient}]}) | |
} |
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 -i -u foo@email.com:123456 -X POST -H 'Content-Type: application/xml' -d '<user><email>foo@example.com</email><postal-code>12345</postal-code></user>' http://0.0.0.0:3000/users.xml | |
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
#git prompt | |
PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND" | |
green=$'\e[1;32m' | |
magenta=$'\e[1;35m' | |
normal_colours=$'\e[m' | |
export PS1="$NM$HI\u@$HII\h:$SI\w$NM\[$magenta\]\$git_branch\[$green\] $ $IN" | |
function find_git_branch { | |
local dir=. head |
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
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get upgrade –y | |
sudo apt-get install vim build-essential libssl-dev openssl curl libxml2-dev libxslt1-dev git-core mysql-server libmysqlclient-dev \ | |
nginx monit ufw monit lynx unixodbc-dev unixodbc tdsodbc freetds-dev freetds-common libreadline5-dev libncurses5-dev libaio-dev -y | |
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) | |
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.profile |
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 Shipment < ActiveRecord::Base | |
has_many :labels | |
accepts_nested_attributes_for :labels | |
end | |
class Label < ActiveRecord::Base | |
belongs_to :shipment | |
end | |
ruby-1.9.2-p180 :001 > s = Shipment.new(:vendor_service_code =>'asdasd', "labels_attributes"=>{"0"=>{"package_weight"=>"1", "insured_value"=>"50"}}) |
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
ruby-1.9.2-p180 :026 > pp bing.news('"global warming" or "climate change" not happening').news.results.first | |
{"Title"=>"Climate change is happening but it's out of man's control", | |
"Url"=> | |
"http://www.sun-sentinel.com/news/opinion/fl-readers-view-global-warming-20120110,0,6201898.story", | |
"Source"=>"Sun Sentinel", | |
"Snippet"=> | |
"does not seem to understand that the science concerning humans being primarily responsible is far from settled. The writer states that global warming/climate change has been happening for 30 to 100 years, which understates the time frame by ...", | |
"Date"=>"2012-01-10T07:53:54Z", | |
"BreakingNews"=>0} |
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 SettingsController < ApplicationController | |
set_tab :settings | |
before_filter :authenticate_user! | |
def edit | |
@user = current_user | |
end | |
def update |
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 RangedHash | |
def initialize(hash) | |
@ranges = hash | |
end | |
def [](key) | |
@ranges.each do |range, value| | |
return value if range.include?(key) | |
end | |
end |
OlderNewer