Oct 16 2010
- 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments
In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].
# Aliases for common git commands. E.g., enter "git d" for "git diff" | |
# These settings live in the ~/.gitconfig file. | |
[alias] | |
b = branch | |
ba = branch -a | |
ci = commit | |
co = checkout | |
d = diff | |
dc = diff --cached |
/* | |
Load Sinon.JS in the SpecRunner: | |
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script> | |
<script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script> | |
<script type="text/javascript" src="sinon-1.0.0.js"></script> | |
<script type="text/javascript" src="sinon-ie-1.0.0.js"></script> | |
http://cjohansen.no/sinon/ | |
*/ |
// Basic XMPP bot example for HipChat using node.js | |
// To use: | |
// 1. Set config variables | |
// 2. Run `node hipchat_bot.js` | |
// 3. Send a message like "!weather 94085" in the room with the bot | |
var request = require('request'); // github.com/mikeal/request | |
var sys = require('sys'); | |
var util = require('util'); |
default_run_options[:pty] = true | |
load 'deploy' if respond_to?(:namespace) # cap2 differentiator | |
require 'capistrano' | |
require 'rubygems' | |
require 'railsless-deploy' | |
set :application, "vault42.org" | |
set :deploy_to, "/usr/local/www/#{application}" | |
set :backup_dir, "/home/tomislav/backup" | |
set :use_sudo, false |
# ** ERROR 1 ** | |
# FATAL: lock file "postmaster.pid" already exists | |
# HINT: Is another postmaster (PID 4646) running in data directory "/usr/local/var/postgres"? | |
# | |
# ** ERROR 2 ** | |
# Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? | |
# | |
# To fix one of this errors: | |
cat /usr/local/var/postgres/postmaster.pid # pid is the number on first line |
// This is the main application configuration file. It is a Grunt | |
// configuration file, which you can learn more about here: | |
// https://github.com/cowboy/grunt/blob/master/docs/configuring.md | |
// | |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
// The clean task ensures all files are removed from the dist/ directory so | |
// that no files linger from previous builds. |
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 |
#Session controller provides a token | |
#/controllers/api/sessions_controller.rb | |
class Api::SessionsController < Devise::SessionsController | |
before_filter :authenticate_user!, :except => [:create] | |
before_filter :ensure_params_exist, :except => [:destroy] | |
respond_to :json | |
def create | |
resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
return invalid_login_attempt unless resource |
# Install MacTex: http://mirror.ctan.org/systems/mac/mactex/mactex-basic.pkg | |
$ sudo chown -R `whoami` /usr/local/texlive | |
$ tlmgr update --self | |
$ tlmgr install ucs | |
$ tlmgr install etoolbox | |
# Install pandoc view homebrew |