Skip to content

Instantly share code, notes, and snippets.

@wrburgess
wrburgess / README.md
Created January 28, 2013 21:41
Spree: Skipping delivery step, but adding back default shipping method and tax calculation

Objective: Skip the delivery step in the Checkout state machine and bring back the ability to add a default shipping method and tax calculation

Approach: Add decorators to the Checkout controller and the Order model (see attached files)

Note: This approach might be better managed by overriding the self.define_state_machine! method of the Checkout model located at app/models/spree/order/checkout.rb. However, this model is rather unstable in the Spree upgrade path and overriding the above classes seems to be simpler to adjust.

@mattratleph
mattratleph / vimdiff.md
Last active April 24, 2024 11:28 — forked from roothybrid7/vimdiff_cheet.md
vimdiff cheat sheet

vimdiff cheat sheet

##git mergetool

In the middle file (future merged file), you can navigate between conflicts with ]c and [c.

Choose which version you want to keep with :diffget //2 or :diffget //3 (the //2 and //3 are unique identifiers for the target/master copy and the merge/branch copy file names).

:diffupdate (to remove leftover spacing issues)

:only (once you’re done reviewing all conflicts, this shows only the middle/merged file)

@l15n
l15n / git-branches-by-commit-date.sh
Created July 13, 2012 08:47 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit's author and author date for each branch. Sort by most recent commit's author date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r
@softr8
softr8 / gist:2955680
Created June 19, 2012 18:13
Rails cache wrapper
module MyApp
# See ActiveSupport::Cache::Store for documentation.
module Cache
class << self
def fetch(key, options = {}, &block)
if block_given?
if ActionController::Base.perform_caching && options && options[:expires_in].to_i > 0
Rails.cache.fetch(key, options, &block)
else
yield
@dstroot
dstroot / install_postgresql.sh
Created June 13, 2012 00:26
Install PostgreSQL on Amazon AMI
#!/bin/bash
###############################################
# To use:
# https://raw.github.com/gist/2776351/???
# chmod 777 install_postgresql.sh
# ./install_postgresql.sh
###############################################
echo "*****************************************"
echo " Installing PostgreSQL"
echo "*****************************************"
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jeffreyiacono
jeffreyiacono / Rakefile
Created February 8, 2012 20:15
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
@netmute
netmute / Molokai.itermcolors
Created December 2, 2011 16:44
iTerm Molokai Colorscheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.48771023750305176</real>
<key>Green Component</key>
<real>0.48781105875968933</real>
@leshill
leshill / Procfile
Created November 28, 2011 20:01
Unicorn config for cedar stack on Heroku.
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
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