Skip to content

Instantly share code, notes, and snippets.


Brad Gessler bradgessler

View GitHub Profile
View csv_definition.rb
require "csv"
class CSVDefinition
attr_reader :definition
def initialize
@definition ||=
def row(name, &block)
bradgessler /
Created Nov 15, 2016
First CLI commands
$ docker run ubuntu /bin/echo 'Hello world'
Hello world
bradgessler / initializer.rb
Last active Mar 10, 2017
MIddleware for making legacy versions of Internet Explorer (anything below 11) work with rails. I release this code under MIT license.
View initializer.rb
# ./config/initializers/rewrite_ie_header.rb
# Don't forget to include the middleware file! If you have a ./lib/middleware folder in rails
# a `require './lib/middleware/rewrite_ie_header.rb'` should do the trick
# IE has a really stupid accept header, so here we scope its domain of mime-types that it can negotiate, otherwise we'll
# end up with weird bugs where if you hit /mcp/:id, IE will download a .ppt file instead of the .html content.
# Issue documented in more detail at
Rails.application.config.middleware.use RewriteIEAcceptHeader do |ie_mime_types|
View bundle
#!/usr/bin/env bash
export IMAGE_NAME=my_app
CONTAINER_ID=$(docker run -d $IMAGE_NAME bundle $@)
docker logs -f $CONTAINER_ID
View pundit_matcher.rb
module PunditExampleGroup
extend ::RSpec::Matchers::DSL
matcher :permit do |action|
match do |policy|
failure_message do |policy|
"#{policy.class} does not permit #{action} on #{policy.record} for #{policy.user.inspect}."
bradgessler / license.rb
Created Jul 2, 2014
Print a list of licenses for gems in a bundle.
View license.rb
require 'bundler'
require 'yaml'
def format(hash)
Bundler.load.specs.each do |spec|
puts format({
bradgessler / list.hon
Last active Dec 29, 2015
JSON is too verbose for hypermedia APIs. HON (Hypermedia Object Notation) preserves the readability and implicit data structure of JSON while with the addition of line attributes for URL and pagination metadata. From
View list.hon
name: "Todo List",
items(href: '/lists/1203/items', next_href: "/lists/1203/items?page=2"): [
item(href: '/items/1'): {
description: "Pick up pizza",
status: "completed"
item(href: '/items/12'): {
description: "Eat pizza",
status: "non_started"
View a.json
a: {
attributes {
href: 'foo.html'
value: 'Click Here'
View link.json
bradgessler /
Last active Dec 16, 2015
Sketch for a Tilt/Markdown extension that makes it a little easier to add structure to markdown after its rendered.
# How to tie your shoes
<%= toc.each do |id, text| %>
* [<%= text %>](#<%= id %>)
<% end %>
## Unlace them
Gotta make sure its untied before you tie it!
You can’t perform that action at this time.