gem install rails
rails new my_app -T
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: supervisord | |
| # Required-Start: $remote_fs | |
| # Required-Stop: $remote_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Example initscript | |
| # Description: This file should be used to construct scripts to be | |
| # placed in /etc/init.d. | 
| set :rails_env, :production | |
| set :unicorn_binary, "/usr/bin/unicorn" | |
| set :unicorn_config, "#{current_path}/config/unicorn.rb" | |
| set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid" | |
| namespace :deploy do | |
| task :start, :roles => :app, :except => { :no_release => true } do | |
| run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D" | |
| end | |
| task :stop, :roles => :app, :except => { :no_release => true } do | 
| echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
| . ~/.bashrc | |
| mkdir ~/local | |
| mkdir ~/node-latest-install | |
| cd ~/node-latest-install | |
| curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
| ./configure --prefix=~/local | |
| make install # ok, fine, this step probably takes more than 30 seconds... | |
| curl https://www.npmjs.org/install.sh | sh | 
| #!/bin/sh | |
| # ------------------------------------------------------------------------------ | |
| # SOME INFOS : fairly standard (debian) init script. | |
| # Note that node doesn't create a PID file (hence --make-pidfile) | |
| # has to be run in the background (hence --background) | |
| # and NOT as root (hence --chuid) | |
| # | |
| # MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit | |
| # INIT-INFO RULES http://wiki.debian.org/LSBInitScripts | |
| # INSTALL/REMOVE http://www.debian-administration.org/articles/28 | 
| # Install RVM and dependencies | |
| sudo aptitude install curl git-core | |
| sudo bash < <( curl -L http://bit.ly/rvm-install-system-wide ) | |
| sudo aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev | |
| sudo adduser `whoami` rvm | |
| echo 'source /usr/local/lib/rvm' >> ~/.bashrc | |
| # Set up users and groups | |
| sudo useradd --home /var/www --create-home --groups rvm unicorn && sudo chmod g+w /var/www | |
| sudo adduser `whoami` unicorn | |
| # | 
| require 'sinatra/base' | |
| require 'memcached' | |
| module Sinatra | |
| module Memcacher | |
| module Helpers | |
| def cache(key, &block) | |
| return block.call unless options.memcacher_enabled | |
| begin | 
| # These are my notes from the PragProg book on CoffeeScript of things that either | |
| # aren't in the main CS language reference or I didn't pick them up there. I wrote | |
| # them down before I forgot, and put it here for others but mainly as a reference for | |
| # myself. | |
| # assign arguments in constructor to properties of the same name: | |
| class Thingie | |
| constructor: (@name, @url) -> | |
| # is the same as: | 
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Leaflet</title> | |
| <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" /> | |
| <script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script> | |
| <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script> | |
| <script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script> | |
| </head> | |
| <body> | 
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |