Skip to content

Instantly share code, notes, and snippets.

View johnbeynon's full-sized avatar

John Beynon johnbeynon

View GitHub Profile
@johnbeynon
johnbeynon / gist:1082256
Created July 14, 2011 10:49
Override Rails3 CSS stylesheet and image path
module ActionView
module Helpers
module AssetTagHelper
def stylesheet_path(source)
compute_public_path(source, "stylesheets/<some sub dir here>", 'css')
end
alias_method :path_to_stylesheet, :stylesheet_path
def image_path(source)
@johnbeynon
johnbeynon / Guardfile
Created July 14, 2011 09:08
Guardfile
guard 'bundler' do
watch('Gemfile')
end
guard 'cucumber' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
@johnbeynon
johnbeynon / gist:924989
Created April 18, 2011 08:31
Installing ImageMagick
brew install -f imagemagick --disable-openmp
@johnbeynon
johnbeynon / Want to use
Created March 30, 2011 08:48
Stuff I Use
In Use:
Devise
CanCan
Kaminari
friendly_id
Papertrail
Carrierwave
Rails Best Practices
Rails Footnotes
Guard
@posts = [3,6,9,10,11,14,15,19,23,24,38,40,42,65,66,70,71,103,106,107,108,109,197,198,199,200,201]
@posts.each { |post| Post.find(post).categories.delete( Category.find 3 ) }
class PurgePostCategories < ActiveRecord::Migration
@posts = [3,6,9,10,11,14,15,19,23,24,38,40,42,65,66,70,71,103,106,107,108,109,197,198,199,200,201]
c = Category.find_by_title('Useful')
def self.up
@posts.each do |post|
Post.find(post).categories.delete(c)
end
end
# download, from_repo, and commit_state methods swiped from
# http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"