Skip to content

Instantly share code, notes, and snippets.

View neilmiddleton's full-sized avatar
🏠
Working from home

Neil Middleton neilmiddleton

🏠
Working from home
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?"
From 63254641c717dbdafdeb92fa0a3b70034d237a91 Mon Sep 17 00:00:00 2001
From: Neil Middleton <neil@monochrome.co.uk>
Date: Thu, 15 Oct 2009 14:32:33 +0100
Subject: [PATCH 2/2] Changes to enable bcms deploment on heroku
---
.gems | 1 +
config/environment.rb | 1 +
config/initializers/browsercms.rb | 7 ++++
config/s3.yml | 9 +++++
conditions = {}
conditions[:age] = params[:age] if params[:age].present?
conditions[:gender] = params[:gender] if params[:gender].present?
# Store named scopes
active = User.scoped(:conditions => {:active => true})
recent = User.scoped(:conditions => ['created_at > ?', 7.days.ago])
# Which can be combined
recent_active = recent.active
# And operated upon
recent_active.each { |u| ... }
Profile.scoped(:conditions => conditions).all(:conditions => ["description LIKE ?", "%#{params[:description]}%")
<%= h some_string %>
is now the same as
<%= some_string %>
<%= some_string.html_safe %>
SELECT * FROM sometable WHERE textfield ILIKE '%value%';
SELECT * FROM sometable WHERE textfield LIKE '%value%';
~ ➔ rvm --trace install ree
--trace install ree
rvm 0.1.38 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
+ [[ -z '' ]]
+ [[ ! -z ree ]]
+ rvm_action=use
+ [[ ! -z '' ]]
+ [[ ! -z '' ]]