Skip to content

Instantly share code, notes, and snippets.

@murdoch
murdoch / failing-build
Created March 17, 2012 14:00
refinery on heroku
stv@home:~/Desktop/refinery$ refinerycms test_123_456 --heroku
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
@murdoch
murdoch / Gemfile
Created November 19, 2011 19:15
Gemfile for peerinstruction
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'haml'
gem 'devise'
gem 'json'
@murdoch
murdoch / hspm.rb
Created October 24, 2011 00:35
has secure password memo
# some notes on using has_secure_password
class User < ActiveRecord::Base
has_secure_password
attr_accessible :login_name, :password, :password_confirmation
# secure_password.rb already checks for presence of :password_digest
# so we can assume that a password is present if that validation passes
# and thus, we don't need to explicitly check for presence of password
@murdoch
murdoch / application.css.sass
Created September 15, 2011 14:32
a gist to illustrate where to place @charset directive in case you run into the dreaded "Invalid US-ASCII character "\xE2"" whilst attempting to pre-compile Sass assets
@charset "UTF-8"
// This is a manifest file that'll automatically include all the stylesheets available in this directory
// and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
// the top of the compiled file, but it's generally better to create a new file per style scope.
//
//= require_self
// Then we'll import the compass and html5-boilerplate extensions
@import compass/utilities
@import html5/boilerplate
@murdoch
murdoch / check-uri.rb
Created August 24, 2011 16:51
Check if uri exists
## just some ways to check if a url exists
# method 1 - from Simone Carletti
require "net/http"
url = URI.parse("http://www.google.com/")
req = Net::HTTP.new(url.host, url.port)
res = req.request_head(url.path)
# method 2 - from some kid on the internet
require 'open-uri'
@murdoch
murdoch / strip-white-space.rb
Created August 24, 2011 16:49
strip white-space from all attributes
# Just a few different methods to strip white-space from all attributes on a model.
# method 1 - code from scott moonen
# http://scottmoonen.com/2009/05/08/rails-pattern-trim-spaces-on-input/
module Trimmer
def self.included base
base.extend(ClassMethods)
end
module ClassMethods