Skip to content

Instantly share code, notes, and snippets.

@jancel
jancel / Gemfile
Created Mar 31, 2014
Example deploy.rb for Capistrano
View Gemfile
source 'https://rubygems.org'
gem 'rails', "3.2.10"
# omitted
group :stage, :production do
gem 'pg'
gem 'unicorn'
end
View gist:2483107
#config/production.rb (line 1)
def compile_asset?(path)
# ignores any filename that begins with '_' (e.g. sass partials)
# all other css/js/sass/image files are processed
if File.basename(path) =~ /^[^_].*\.\w+$/
puts "Compiling: #{path}"
true
else
puts "Ignoring: #{path}"
View gist:1860426
def build_table
build_table_head
build_table_body unless @collection.blank?
end
versus
def build_table
build_table_head
@jancel
jancel / gist:1367606
Created Nov 15, 2011 — forked from r00k/gist:906356
Custom devise strategy
View gist:1367606
# In config/initializers/local_override.rb:
require 'devise/strategies/authenticatable'
module Devise
module Strategies
class LocalOverride < Authenticatable
def valid?
true
end
@jancel
jancel / gist:913662
Created Apr 11, 2011
an example from my parser
View gist:913662
require 'spec_helper'
describe Parser do
def parser(str = nil)
Parser.new(str)
end
describe "when initialized" do
describe "with a valid string" do
View gist:884196
def fizzbuzz( number, index = 1 )
if index <= number
if index % 3 == 0 && index % 5 == 0
p "fizzbuzz"
elsif index % 3 == 0
p "fizz"
elsif index % 5 == 0
p "buzz"
else
p index
View gist:780454
#application controller
around_filter :update_user_seen_on
def update_user_seen_on
yield
if signed_in?
current_user.last_seen_on = DateTime.now
current_user.save
You can’t perform that action at this time.