⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
require 'factory_girl_rails' | |
require 'rspec' | |
require 'rspec-rails' | |
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example) | |
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user` | |
def reload_factories! | |
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences | |
# FactoryGirl.instance_variable_set(:@sequences, nil) |
#!/usr/bin/env ruby | |
require 'test/unit' | |
class TestSums < Test::Unit::TestCase | |
def setup | |
@a = [2, 5, 18, 27] | |
@sum = 0 | |
end |
Dir.glob("**/*.png").each do |file| | |
['pngnq -e .png -f', 'pngquant -f -speed 1 -ext .png', 'pngcrush'].each do |command| | |
puts "#{command} #{file}" | |
`#{command} #{file}` | |
end | |
end |
This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.
# Ensure system is in ship-shape.
aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev
Recently, I had a staging database on Heroku that was running on the Ronin database (which was originally the lowest-sized DB you could get at Heroku). Since they added two new options, Crane and Kappa, we wanted to take advantage of the cost savings. Here's how you can migrate your Ronin DB to Crane (or any other plan).
The old database was named BROWN while the new one is CRIMSON. You can determine this by running:
heroku pg:info --app myapp-staging
-
Add Crane database
heroku addons:add heroku-postgresql:crane --app myapp-staging
heroku pg:wait --app myapp-staging
Spree::Order.class_eval do | |
silence_warnings do | |
state_machines.clear | |
#override state_machine to add choose_reward step | |
state_machine :initial => 'cart', :use_transactions => false do | |
event :next do | |
transition :from => 'cart', :to => 'address' | |
transition :from => 'address', :to => 'delivery' | |
transition :from => 'delivery', :to => 'payment', :if => :payment_required? | |
transition :from => 'delivery', :to => 'complete' |
# place this file in ~/.config/terminator/config | |
[global_config] | |
title_transmit_bg_color = "#d30102" | |
focus = system | |
[keybindings] | |
reset_clear = <Ctrl>R | |
new_tab = <Ctrl>T | |
split_horiz = <Ctrl><Shift>E | |
split_vert = <Ctrl>E | |
close_term = <Ctrl><Shift>W |
#!/usr/bin/env ruby | |
#Place this in your root directory of your rails app | |
#Ensure that you have install thor gem | |
#To list the command, type 'thor -T' | |
module Heroku | |
class Db < Thor | |
desc "production_to_local", "clone a remote heroku database to the local environment" | |
method_option :remote_production, :type => :string, :default => 'production' |