This file contains hidden or 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
production: | |
adapter: postgresql | |
encoding: unicode | |
pool: 5 | |
database: <%=ENV['OPENSHIFT_APP_NAME']%> | |
host: <%=ENV['$OPENSHIFT_POSTGRESQL_DB_HOST']%> | |
port: <%=ENV['$OPENSHIFT_POSTGRESQL_DB_PORT']%> | |
username: <%=ENV['OPENSHIFT_POSTGRESQL_DB_USERNAME']%> | |
password: <%=ENV['OPENSHIFT_POSTGRESQL_DB_PASSWORD']%> |
This file contains hidden or 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
server { | |
listen 80; | |
root /home/username/example.com; | |
index index.php index.html; | |
server_name example.com; | |
location / { | |
try_files $uri $uri/ /index.php?q=$uri&$args; |
This file contains hidden or 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 Book < ActiveRecord::Base | |
attr_accessible :title, :author, :lang, :genre, :shelf_id | |
belongs_to :shelves | |
def enshelf shelf_id | |
@book.shelf_id = shelf_id | |
end | |
def unshelf | |
# setting shelf_id to nil means book is not on the shelf |
This file contains hidden or 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
# silly_sum | |
def silly_sum numbers | |
sum = 0 | |
numbers.each_with_index {|number, index| | |
sum = sum + number*index | |
} | |
puts "sum = #{sum}" | |
end | |
puts "### silly_sum ###" |
This file contains hidden or 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
# assuming the file is there in the same dir as numbers.txt | |
file = File.open("numbers.txt", 'r') | |
frequency_db = Hash.new | |
file.each_line do |line| | |
line_n = line.split | |
line_n.each do |n| | |
if frequency_db.has_key?(n) | |
frequency_db[n]+=1 |
This file contains hidden or 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
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName example.com | |
DocumentRoot /home/user_name/example.com/ | |
</VirtualHost> | |
<VirtualHost *:80> | |
ServerName www.example.com | |
Redirect permanent / http://example.com/ | |
</VirtualHost> |
This file contains hidden or 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: | |
adapter: sqlite3 | |
database: db/development.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
test: | |
adapter: sqlite3 | |
database: db/test.sqlite3 | |
pool: 5 |
This file contains hidden or 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
require "bundler/capistrano" | |
#require "delayed/recipes" | |
server "YOUR_IP_ADDRESS", :web, :app, :db, primary: true | |
set :rails_env, "production" #added for delayed job | |
set :application, "YOUR_APP_NAME" | |
set :user, "mrhuman" | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :deploy_via, :remote_cache |
This file contains hidden or 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 | |
set -e | |
# Feel free to change any of the following variables for your app: | |
TIMEOUT=${TIMEOUT-60} | |
APP_ROOT=/home/mrhuman/apps/YOUR_APP_NAME/current | |
PID=$APP_ROOT/tmp/pids/unicorn.pid | |
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production" | |
AS_USER=mrhuman | |
set -u |
This file contains hidden or 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
load 'deploy' | |
# Uncomment if you are using Rails' asset pipeline | |
load 'deploy/assets' | |
load 'config/deploy' # remove this line to skip loading any of the default tasks |