Skip to content

Instantly share code, notes, and snippets.

# change foo to your library name
# change Foo::Database to your Sequel database
namespace :bundler do
task :setup do
require 'rubygems'
require 'bundler/setup'
end
end
require 'bundler/capistrano'
set :application, "net"
set :repository, "[email protected]:net.git"
set :scm, :git
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
require 'sinatra'
require 'mongoid'
require 'json'
require "sinatra/reloader" if development?
Mongoid.load!("mongoid.yml")
class Price
include Mongoid::Document
# Requires ImageMagick
# Converting the source from JPEG to PNG - if necessary
convert my_src_image.jpg my_src_image.png
# Option A
# - Requires a temporary intermediate file
# - Drill more than 10 might result in poor results
2 tone
2-step garage
4-beat
4x4 garage
8-bit
acapella
acid
acid breaks
acid house
acid jazz
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@bertomartin
bertomartin / bst.rb
Created January 3, 2014 20:09 — forked from jcasimir/bst.rb
class Bst
attr_reader :data, :left, :right
def initialize(input)
@data = input
end
def all
result = []
module APIControllerTest
def get_json(action, params = {})
get action, params.merge(:format => :json)
assert_response :success
JSON.parse(@response.body)
end
def assert_status(expected_code)
assert_equal expected_code, @response.status
end

Exposing an API

APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.

In the Controller

Let's work with the following example controller:

class ArticlesController &lt; ApplicationController

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: