This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~* "-[a-z0-9]{32}\.(png|gif|jpg|jpeg|css|js)$" { | |
expires max; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo < ActiveRecord::Base | |
before_save :strip_empty_strings | |
def strip_empty_strings | |
self.class.columns.select{ |c| c.type == :string }.each do |c| | |
send "#{c.name}=", send(c.name).try(:strip).presence # sets to nil if completely empty | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Example | |
class Application < Rails::Application | |
# Loads ruby files in a given directory. | |
# NOTE: `require_dependency` auto-reloads on file change when in development. | |
# POSTERITY: this was needed to prevent auto-namespacing of lib/a/b.rb files. | |
def loader(*dirs) | |
dirs.each do |dir| | |
Dir["#{Rails.root}/#{dir}/*.rb"].each do |path| | |
d = dir.gsub /lib\/?/, '' # removes lib and lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: &default | |
adapter: postgresql | |
database: app_development | |
connect_retry_timeout: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# setup | |
class User | |
def name; 'Bob'; end | |
end | |
class Object | |
def wrap(method, &block) | |
prepend Module.new { define_method method, &block } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Child < ActiveRecord::Base | |
belongs_to :parent | |
INHERITABLE_SETTINGS = %i[foo bar baz] | |
INHERITABLE_SETTINGS.each do |attr| | |
define_method attr do | |
value = read_attribute(attr) | |
default = default_setting(attr) | |
inherited = inherited_setting(attr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def at(time) | |
original = Time.now | |
allow(Time).to receive(:now) { time } | |
yield | |
ensure | |
allow(Time).to receive(:now) { original } | |
end | |
at 12.hours.from_now do | |
# your test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rails', '3.2.0' | |
gem 'mysql2' | |
# Using this branch of ActiveAdmin to allow batch editing of records. | |
#gem 'activeadmin', :git => 'https://github.com/mattvague/active_admin.git', :branch => '270_batch_edit_api' | |
gem 'activeadmin', '0.4.0' | |
gem 'sass-rails', '3.2.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rakefile inspired by http://rhnh.net/2010/09/07/speeding-up-rails-rake | |
def load_rails_environment | |
require File.expand_path('../config/application', __FILE__) | |
require 'rake' | |
TimeAudit::Application.load_tasks | |
end | |
# By default, do not load the Rails environment. This allows for faster | |
# loading of all the rake files, so that getting the task list, or kicking | |
# off a spec run (which loads the environment by itself anyways) is much quicker. |
OlderNewer