Moral of the story: switch out of Java before the world gets too dependent on them ;)
1. Make sure RSpec is already running.
2. Add this in your Gemfile
# Gemfile gem 'spork' |
3. In your project application root, create a .rspec file if its not already created and add –drb in the first line.
# .rspec --drb |
4. Add Spork.prefork block into spec_helper.
# spec/spec_helper.rb require 'spork' Spork.prefork do ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' end |
5. Reload Spork
6. Done!
Just gave Twilio a whirl on a project that I’m working on with the help of credits won from the StartupPack raffle (Thanks StartupPack!).
Integration was really quick with the help of Steve Graham’s Twilio-RB gem.
Surprisingly, the SMS do come in almost immediately despite coming from half the globe away.
According to theorists, We know that space and time wrap around itself and that it MAY possible to go back in time (through mechanisms like wormholes etc…). After all, we’re all just energy and molecules.
At the same time, we hear stories about how Karma tend to flow forwards. A good deed done today, will perhaps be sowed in the future in a different life.
Assuming that the Buddhist concept of rebirth is true, what if, when you die, you don’t actually get reborn in a time in the future, but actually in the past. Your your son, could technically be reborn as your father and your relationship with each other, could be connected through the karma seeds sown in ‘your future son’.
Your son could be paying his debts to you as his father, by being reborn as your father. Hence creating a cycle and circle of connectedness, or Karma.
The other day on a single-day internal hackathon, together with Ernest and the rest of the One Cent Movement guys, we decided to do up an internal check-in mobile webapp where we can see where each of us were at anytime of the day.
This is a simple guide to deploy your node.js app onto a production server. Which in my case is an Amazon EC2 m1.small instance.
Pre-requsite:
- NPM is assumed to be the defacto package manager. You have package.json running on your app root.
- You’ve setup a deployment on your server using Capistrano before. So all user authentication, keys, git repository authorization has all already been set up before hand.
- Nodejs is already installed (sudo apt-get install nodejs).
- Forever will be used.
Step 0:
In your package.json, make sure forever is in your dependencies and that you’ve done a npm install.
# /approot/package.json { "name": "hello-world", "description": "hello world test app", "version": "0.0.1", "private": true, "dependencies": { "forever" : "*" } } |
Step 1:
Create a Gemfile in your application root and do a bundle install
# /approot/Gemfile gem 'cappers' |
Cappers is a modified fork of Capistrano
Step 2:
Capify your /approot.
/approot$ capify . |
Step 3:
Copy and paste the following deploy.rb file into config/deploy.rb
set :application, "Myapp" set :repository, "ssh://git@bitbucket.org/yourrepo/app.git" set :deploy_to, "/approot" set :user, 'deployer' set :use_sudo, false set :use_nave, false set :main_js, 'server.js' set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` role :web, "<ip>" # Your HTTP server, Apache/etc role :app, "<ip>" # This may be the same as your `Web` server role :db, "<ip>", :primary => true # This is where Rails migrations will run set :node_env, 'production' set :forever_cmd, './node_modules/.bin/forever' desc "tail the application logfile" task :log do log = "#{application_dir}/current/log/#{node_env}.log" run "tail -f #{log}" end |
Step 4:
Modify your Capfile
# /approot/Capfile # Capfile require 'rubygems' require 'capper' load 'capper/npm' load 'capper/forever' load 'capper/nave' load 'config/deploy' # remove this line to skip loading any of the default tasks |
Step 5:
In your sites-available/ directory, create the following vhost: (usually in /etc/nginx/sites-available or /opt/nginx/sites-available)
upstream app { server localhost:3000; # if your nodejs is listening on a different port, modify the port value here. } server { server_name your.domain.com; access_log /webapps/spirit/shared/log/spiritapp.log; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; } } |
Step 6:
/approot$ cap deploy |
Source Readings:
[1] http://big-elephants.com/2012-07/deploying-node-with-capistrano/
RVM Ruby 2.0.0-rc1 installs giving you problem?
Getting this Error?
Error running 'make', please read /Users/katz/.rvm/log/ruby-2.0.0-rc1/make.log |
OSX
brew install openssl rvm get head CC=clang rvm install 2.0.0 -C --enable-shared, --with-openssl-dir=/usr/local |
Ubuntu
sudo apt-get install openssl rvm get head rvm install 2.0.0 -C --enable-shared, --with-openssl-dir=/usr/local |
Source: http://www.blog.bridgeutopiaweb.com/post/install-ruby-2-dot-0-0-with-rvm
For MariaDB installations, remember to apt-get:
sudo apt-get install libmariadbclient-dev |
Instead of libmysqlclient-dev
http://philbayfield.com/2010/07/11/switching-mysql-for-mariadb-on-ubuntu/
If you’re having issues like the following after updating your ‘rvm-capistrano’ gem:
$rvm_path (/home/myuser/.rvm/) does not exist. |
Even after ensuring that your deploy.rb looks somewhat like:
set :rvm_type, :system set :use_sudo, false |
You should do the following:
# move require 'rvm/capistrano' to the bottom of your deploy.rb # config/deploy.rb . . . . . # some code . require 'rvm/capistrano' |
For future reading:
Devise Wiki – Omniauth Overview
Managing Multiple Identities
If you haven’t heard already, New Zealand’s Parliament had recently legalized same-sex marriage in a 77-44 vote. This means, same-sex married couples will have the same rights and benefits like any other hetrosexual married couple in the country.
Equality truimphs and Strangers break out into a traditional Maori love song.
Congratulations New Zealand!
Bonus:
Meet MP Maurice Williamson and his hilarious speech a day after the bill was passed.
Additional Reading:
NZ’s same-sex marriage go-ahead puts our leaders to shame