Skip to content

Instantly share code, notes, and snippets.

View soutaro's full-sized avatar

Soutaro Matsumoto soutaro

View GitHub Profile
@soutaro
soutaro / gist:1111375
Created July 28, 2011 11:00
Ensure your remote branch is up to date
set :deploy_via, :remote_cache
set :branch, "release"
namespace :git do
namespace :ensure do
desc "Check if your local branch is synched with remote branch"
task :pushed do
local = `git rev-parse #{branch}`.chomp
remote = `git rev-parse remotes/origin/#{branch}`.chomp
@soutaro
soutaro / resize_and_crop.rb
Created November 26, 2010 08:12
resize and crop using using MiniMagick
def resize_and_crop(blob, w0, h0, w1, h1)
image = MiniMagick::Image.read(blob)
rw = w1.to_f / w0
rh = h1.to_f / h0
unless rw > 1 or rh > 1
w,h = w1, h1
sx, sy = 0, 0