Skip to content

Instantly share code, notes, and snippets.

View bkeepers's full-sized avatar

Brandon Keepers bkeepers

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bkeepers on github.
  • I am bkeepers (https://keybase.io/bkeepers) on keybase.
  • I have a public key whose fingerprint is 8AF6 4385 E45B 03AA 72D7 DE72 F524 D391 D545 3EF9

To claim this, I am signing this object:

@bkeepers
bkeepers / gist:8337479
Created January 9, 2014 16:45
Follow link without sending referrer.
//= require lib/jquery
//= require csrf
function openWithoutReferrer(url) {
var site = window.open("", "hide_referrer");
site.document.open();
site.document.writeln('<script type="text/javascript">window.location = "' + url + '";</script>');
site.document.close();
}
@bkeepers
bkeepers / api_spec.rb
Created September 20, 2013 15:41
Use HyperClient to test your Hypermedia API
# spec/features/api_spec.rb
require 'spec_helper'
describe 'API' do
class TestClient < Hyperclient::EntryPoint
def default_faraday_block
lambda do |faraday|
faraday.request :json
faraday.response :json, content_type: /\bjson$/
faraday.adapter :rack, Capybara.app
@bkeepers
bkeepers / gist:6502229
Last active December 22, 2015 16:49
My micro-talk to the Grand Rapids Ruby Group on separating code and configuration.
/$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$$$ /$$$$$$ /$$$$$$
/$$__ $$ /$$__ $$| $$$ | $$| $$_____/|_ $$_/ /$$__ $$
| $$ \__/| $$ \ $$| $$$$| $$| $$ | $$ | $$ \__/
| $$ | $$ | $$| $$ $$ $$| $$$$$ | $$ | $$ /$$$$
| $$ | $$ | $$| $$ $$$$| $$__/ | $$ | $$|_ $$
| $$ $$| $$ | $$| $$\ $$$| $$ | $$ | $$ \ $$
@bkeepers
bkeepers / gist:6002211
Last active December 19, 2015 18:58
I'm looking for a better pattern for defining a method that takes a single object or an array of objects as an argument, does something with them, and then returns either a single object or an Array depending on what was passed to it.
def dress(dog_or_dogs)
dressed_dogs = Array(dog_or_dogs).map {|dog| DogSweater.new(dog) }
dog_or_dogs.respond_to?(:each) ? dressed_dogs : dressed_dogs.first
end
one_dog = dress(Dog.new)
all_my_dogs = dress([Dog.new, Dog.new, Dog.new])
@bkeepers
bkeepers / twithubbers.sh
Created June 4, 2013 14:29
Create a list of GitHubbers and follow all of them.
#!/bin/sh
#
# Requires the `t` gem: https://github.com/sferik/t
#
# gem install t
#
if [ -z $(t lists | grep -i githubbers) ]
then
t list create GitHubbers
@bkeepers
bkeepers / frameworks.md
Created May 14, 2013 13:00
Frameworks for building HTML+CoffeeScript+[CSS-preprocessor] sites.
@bkeepers
bkeepers / .gitconfig
Created February 19, 2013 14:12
Git aliases to make new commits that fixup or are squashed into previous commits
[alias]
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase -i --autosquash $REV^' -
squash = !sh -c 'REV=$(git rev-parse $1) && git commit --squash $@ && git rebase -i --autosquash $REV^' -