Skip to content

Instantly share code, notes, and snippets.

View johnbeynon's full-sized avatar

John Beynon johnbeynon

View GitHub Profile
# 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?"
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
@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 ) }
@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
@johnbeynon
johnbeynon / gist:924989
Created April 18, 2011 08:31
Installing ImageMagick
brew install -f imagemagick --disable-openmp
@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: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 / heroku.coffee
Created November 12, 2011 22:19
Heroku Hubot Script
# A limited way to interact with the Heroku API.
#
# INSTALLATION:
# 1. Create file in scripts folder in hubot folder
# 2. Update package.json for hubot and add dependency on "sprintf": "0.1.1"
# 3. Set heroku config variable HEROKU_USER to heroku user account to use
# 4. Set heroku config variable HEROKU_APIKEY to heroku user account apikey (from My Account page)
#
# heroku status - Retrieve the most recent tweet from the @herokustatus account
# heroku ps --app <appname> - Get process information for application
GIT
remote: git://github.com/jnicklas/carrierwave.git
revision: 181620a505b45e1a9b919278a213036a4fd7c89f
specs:
carrierwave (0.5.8)
activesupport (>= 3.0)
GEM
remote: http://rubygems.org/
specs:
Loading development environment (Rails 3.2.0.rc2)
>> Photo.last
Photo Load (0.9ms) SELECT "photos".* FROM "photos" ORDER BY "photos"."id" DESC LIMIT 1
#<Photo:0x007fabb4fb0da8> {
:id => 15,
:user_id => 1,
:yacht_id => 11,
:image => "DSCF2077.jpeg",
:primary => false,
:created_at => Fri, 30 Dec 2011 09:16:48 UTC +00:00,