Skip to content

Instantly share code, notes, and snippets.

@jcowhigjr
jcowhigjr / registrations_controller.rb
Created October 29, 2012 17:22 — forked from jwo/registrations_controller.rb
API JSON authentication with Devise
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
@jcowhigjr
jcowhigjr / spree-api-rest-examples.md
Created November 5, 2012 23:58
Spree API REST Examples

Products

index of products 25 first

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products.json

Show a product

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products/706676762.json

Modify a product

curl -i -X PUT -H "X-Spree-Token: YOUR_TOKEN_ID" -d "product[name]=Headphones" http://0.0.0.0:3000/api/products/706676762.json

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
  1. Add Crane database

     heroku addons:add heroku-postgresql:crane --app myapp-staging
    

heroku pg:wait --app myapp-staging

#!/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'

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
class config::sublime {
define addpkg {
$packagedir = "/Library/Application Support/Sublime Text 2/Packages/"
$pkgarray = split($name, '[/]')
$pkgname = $pkgarray[1]
exec { "git clone https://github.com/${name}.git":
cwd => "/Users/${::luser}${packagedir}",
provider => 'shell',
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)
@jcowhigjr
jcowhigjr / Gemfile
Created December 18, 2013 20:27 — forked from SammyLin/Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'jquery-rails'
# A Scope & Engine based, clean, powerful, customizable and sophisticated paginator
gem "kaminari"
# Compass is a Stylesheet Authoring Environment that makes your website design simpler to implement and easier to maintain.
@jcowhigjr
jcowhigjr / ubuntu_steps.sh
Last active January 2, 2016 13:19 — forked from july-12/ubuntu_steps.sh
RAILS Stack build steps
# from ubuntu trusty 13.10
# As root user
sudo su
# Update the OS
apt-get update -y
# Add this to ~/.bashrc to remove timezone warnings
export LC_ALL="en_US.UTF-8"