I hereby claim:
- I am buren on github.
- I am buren (https://keybase.io/buren) on keybase.
- I have a public key whose fingerprint is EBA4 FF7D C0DF C205 02B8 9A24 C85F B75E 410E 4CC4
To claim this, I am signing this object:
| # Rails StrongParameters refactor | |
| # | |
| # Inspired by Ryan Bates's Screencast #371 | |
| # http://railscasts.com/episodes/371-strong-parameters | |
| # | |
| # A simple pattern to refactor permitted params for Rails with StrongParameters. | |
| # app/models/author.rb | |
| class Author < ActiveRecord::Base | |
| validates_presence_of :name, :birth_date |
| # config/initializers/web_console.rb | |
| WebConsoleBeforeAction = ->(controller) do | |
| controller.console if controller.params[:web_console] | |
| end | |
| ApplicationController.before_action(WebConsoleBeforeAction) if defined?(WebConsole) && Rails.env.development? | |
| # NOTE: | |
| # For security reasons only do this in development. |
| class Meta | |
| def self.make_method(meth_name) | |
| define_method meth_name do |adjective| | |
| puts "#{meth_name} is a #{adjective} method name" | |
| end | |
| end | |
| def method_missing(meth, *args, &block) | |
| puts "Method #{meth} is not defined on this class" | |
| self.class.make_method(meth) |
| # https://gist.github.com/buren-trialbee/f51c6d37ea96618bcc49 | |
| task :console do | |
| require 'irb' | |
| require 'irb/completion' | |
| require 'my_gem' | |
| ARGV.clear | |
| IRB.start | |
| end |
| require 'uri' | |
| require 'net/http' | |
| require 'openssl' | |
| MAX_ATTEMPTS = 2 | |
| # Get response given an URL and follow redirects | |
| def self.url_response(uri) | |
| found = false | |
| url = URI.parse(uri) |
| package utils; | |
| import java.net.URL; | |
| public class Enduro { | |
| private static Enduro ourInstance = new Enduro(); | |
| public static Enduro getInstance() { | |
| return ourInstance; | |
| } |
I hereby claim:
To claim this, I am signing this object:
| class RetryableCall | |
| DEFAULT_OPTIONS = { | |
| sleep: 0.5, | |
| max_retries: 5 | |
| } | |
| def self.perform options = {}, &block | |
| new(options).perform(&block) | |
| end |
| # Shameless steal from http://askubuntu.com/a/85111 | |
| # git branch in zsh-prompt | |
| echo ' | |
| autoload -Uz vcs_info | |
| precmd () { vcs_info } | |
| setopt prompt_subst | |
| PS1="\$vcs_info_msg_0_$PS1"' >> ~/.zshrc |
(Below is an example with MySQL)
Customize config/database.yml to handle multiple databases.
<%
# How to setup a custom database for a branch
branch = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '')
suffix = `git config --bool branch.#{branch}.database`.chomp == 'true' ? "_#{branch}" : "_development"