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 reify_has_manys(model, lookback) | |
model.class.reflect_on_all_associations(:has_many).each do |assoc| | |
# Get live children. | |
children = model.send assoc.name | |
# Ensure child models are using PaperTrail. | |
if children.first.respond_to? :version_at | |
# Handle updated children, and children created since the parent's version. | |
children_then = [] | |
children.each do |child| | |
if (child_as_it_was = child.version_at(created_at - lookback.seconds)) |
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
module ApplicationHelper | |
def inside_layout(layout = 'application', &block) | |
render :inline => capture_haml(&block), :layout => "layouts/#{layout}" | |
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
<MedlineCitation Owner="NLM" Status="MEDLINE"> | |
<PMID Version="1">19663746</PMID> | |
<DateCreated> | |
<Year>2009</Year> | |
<Month>08</Month> | |
<Day>11</Day> | |
</DateCreated> | |
<DateCompleted> | |
<Year>2010</Year> | |
<Month>03</Month> |
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
1313 | Streptococcus pneumoniae | | scientific name | | |
1313 | Streptococcus pneumoniae (Klein 1884) Chester 1901 | | authority | | |
10728 | Streptococcus pneumoniae bacteriophage HB-3 | | synonym | | |
10728 | Streptococcus pneumoniae phage HB-3 | | scientific name | | |
12402 | phage EJ-1 #note host Streptococcus pneumoniae | | misspelling | | |
120574 | Streptococcus pneumoniae bacteriophage MM1 | | synonym | | |
170187 | Streptococcus pneumoniae TIGR4 | | scientific name | | |
171101 | Streptococcus pneumoniae (strain ATCC BAA-255 / R6) | | synonym | | |
171101 | Streptococcus pneumoniae R6 | | scientific name | | |
171101 | Streptococcus pneumoniae str. R6 | | synonym | |
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 new-git () { | |
ssh git@example.com "mkdir $1.git && cd $1.git && git --bare init" | |
git remote add origin git@example.com:$1.git | |
git push origin master | |
git config branch.master.remote origin | |
git config branch.master.merge refs/heads/master | |
git config push.default current | |
} |
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
sudo passenger-install-apache2-module | |
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.9. | |
This installer will guide you through the entire installation process. It | |
shouldn't take more than 3 minutes in total. | |
Here's what you can expect from the installation process: | |
1. The Apache 2 module will be installed for you. | |
2. You'll learn how to configure Apache. |
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 ->(e){ p=Hash[*e['QUERY_STRING'].split(/[&=]/)]; [200, {'Content-type'=>'text/html'}, ["Hello #{p['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
#!/bin/sh | |
BRANCH=$(git name-rev HEAD | cut -d' ' -f2) | |
if [ "$BRANCH" = "staging" -o "$BRANCH" = "production" ] | |
then | |
echo "You must not commit to staging or production." | |
exit 1 | |
fi |
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/sh | |
# | |
# nginx - this script starts and stops the nginx daemon (Centos) | |
# | |
# chkconfig: - 85 15 | |
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \ | |
# proxy and IMAP/POP3 proxy server | |
# processname: nginx | |
# config: /usr/local/nginx/conf/nginx.conf | |
# pidfile: /usr/local/nginx/logs/nginx.pid |
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
@reboot cd /var/www/apps/myapp/current && bundle exec unicorn -c /var/www/apps/myapp/current/config/unicorn.rb -E production -D |