Skip to content

Instantly share code, notes, and snippets.

Jacob Burenstam buren

Block or report user

Report or block buren

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
buren / gist:6961940
Last active Jun 1, 2017
Custom database for rails branch
View gist:6961940

Custom database for Rails branch

(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"
buren / zsh-git-prompt
Last active Aug 29, 2015
View zsh-git-prompt
# Shameless steal from
# git branch in zsh-prompt
echo '
autoload -Uz vcs_info
precmd () { vcs_info }
setopt prompt_subst
PS1="\$vcs_info_msg_0_$PS1"' >> ~/.zshrc
buren / RetryableCall.rb
Created Apr 16, 2014
Retry given block until response is not nil or max_retries is reached
View RetryableCall.rb
class RetryableCall
sleep: 0.5,
max_retries: 5
def self.perform options = {}, &block

Keybase proof

I hereby claim:

  • I am buren on github.
  • I am 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:

buren /
Created May 7, 2014
Simple Java Singelton Example
package utils;
public class Enduro {
private static Enduro ourInstance = new Enduro();
public static Enduro getInstance() {
return ourInstance;
buren / response_follow_redirect.rb
Last active Aug 8, 2016
Get response given an URL and follow redirects
View response_follow_redirect.rb
require 'uri'
require 'net/http'
require 'openssl'
# Get response given an URL and follow redirects
def self.url_response(uri)
found = false
url = URI.parse(uri)
buren / gem_console.rb
Created Oct 5, 2014
Put this in the Gem's Rakefile.
View gem_console.rb
task :console do
require 'irb'
require 'irb/completion'
require 'my_gem'
buren / meta_ruby.rb
Created Oct 22, 2014
Simple Ruby meta programming example
View meta_ruby.rb
class Meta
def self.make_method(meth_name)
define_method meth_name do |adjective|
puts "#{meth_name} is a #{adjective} method name"
def method_missing(meth, *args, &block)
puts "Method #{meth} is not defined on this class"
buren / rails_web_console_param.rb
Last active Feb 13, 2016
Attach a rails web console to any page by adding ?web_console=
View rails_web_console_param.rb
# config/initializers/web_console.rb
WebConsoleBeforeAction = ->(controller) do
controller.console if controller.params[:web_console]
ApplicationController.before_action(WebConsoleBeforeAction) if defined?(WebConsole) && Rails.env.development?
# For security reasons only do this in development.
buren / rails_strong_parameters_refactor.rb
Last active Apr 10, 2017
A simple pattern to refactor permitted params for Rails with StrongParameters included.
View rails_strong_parameters_refactor.rb
# Rails StrongParameters refactor
# Inspired by Ryan Bates's Screencast #371
# 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
You can’t perform that action at this time.