Skip to content

Instantly share code, notes, and snippets.

Brad Gessler bradgessler

Block or report user

Report or block bradgessler

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
bradgessler / cors_policy.rb
Last active Dec 11, 2015
An idea for a Rails CORS policy DSL implementation.
View cors_policy.rb
# Configuration DSL, probably in config/initializers/cors.rb
CORS::Policy.configure do
policy :polleverywhere do
origins '', ''
# I think allowable request method can be inferred by Rails routing.
# methods :get, :put, :post, :delete, :patch
headers 'X-Custom-Request-Header'
expose 'X-Custom-Response-Header'
bradgessler / phone_numbers.rb
Created Nov 7, 2012
A list of all US and Canadian phone numbers
View phone_numbers.rb
#!/usr/bin/env ruby
("000-000-0000").upto("999-999-9999").each do |number|
puts number
bradgessler / blinksale_report.rb
Created Nov 7, 2012
Generate a report by month for the amount of payment received in Blinksale
View blinksale_report.rb
require 'open-uri'
require 'nokogiri'
require 'filecache'
require 'logger'
require 'date'
require 'pry'
# When do you want to grab invoices? Default is 90 days ago.
@since = ENV.include?('SINCE') ? Date.parse(ENV['SINCE']) : - 90
# Blinksale username
bradgessler / posterous-importer.php
Created Jul 27, 2012
Posterous WordPress importer (this one makes sure that the links don't break)
View posterous-importer.php
Plugin Name: Posterous Importer
Plugin URI:
Description: Import posts, comments, tags, and attachments from a blog.
Author: Automattic, Brian Colinger, Peter Westwood, Daryl L. L. Houston
Author URI:
Version: 0.10
License: GPL v2 -
bradgessler / forkin_manifest.rb
Created Apr 18, 2012
A faster Sprockets compiler that breaks apart the job into subprocesses
View forkin_manifest.rb
require 'sprockets'
module Sprockets
module Forkin
class Manifest < ::Sprockets::Manifest
attr_reader :workers
# The last argument should be the number of workers
def initialize(environment, path, workers=1)
@workers = workers
View gist:2357908
A [common criticism]( of building applications outside of Rails is the loss of a great, integrated tool chain.
> You don't pick Rails as the engine for powering your API simply for the asset pipeline, you pick it for all the other stuff @macaw pointed out! If you hook up Sinatra and Sprockets, you are without Rails' ORM, migrations, generators, routing, test infrastructure, plugin ecosystem, and arguably most importantly, the conventions and agility.
There is some truth to that, but it doesn't have to be that way.
I'm going to pick on ActiveRecord. The internet is [littered]( [with]( [posts]( about using ActiveRecord outside of Rails. Most solutions involve hacking together a Rake file that deals with this stuff. Its a pain.
Rails has alread
bradgessler /
Created Feb 15, 2012
Say any URL on a Mac
curl -s | sed -n -e 's/.*<p>\(.*\)<\/p>.*/\1/p' | sed -e "s/<[^>]*>//g" | say
bradgessler / crash.rb
Created Sep 23, 2011
Fiber seg fault
View crash.rb
require 'rubygems'
require 'eventmachine'
require 'fiber'{{}.resume }
/Users/bgessler/Desktop/crash.rb:6: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
bradgessler / asink.rb
Created Sep 14, 2011
Async Thin web server app for testing timeouts
View asink.rb
require 'rubygems'
require 'thin'
# curl "http://localhost:10001/?wait=5&status=500"
# ---
# wait - How many seconds should I wait before returning the status?
# status - HTTP return code
Thin::Server.start('', 10001,{|env|
req =
bradgessler / .rvmrc
Created Jul 29, 2011
rvmrc file that controls the version of Ruby, the Gemset, Rubygems, and Bundler. Use this if you want to control this stuff in your development workflow.
View .rvmrc
#!/usr/bin/env bash
# Bare minimum Gems that are needed to keep a Ruby development environment in sync. This assumes
# that you use bundler in your workflow to control the installation of all other gems. If you need
# to bump the bundler or rubygem version across your team, change that here, then run bundler and
# and keep going.
You can’t perform that action at this time.