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
bradgessler / sketch.md
Last active Dec 16, 2015
Why merge backburner with quebert?
View sketch.md

Assessment of Quebert & Backburner to figure out how to merge the two.

Quebert

  1. Build out an async proxy in place of #async_send so that TTR, delays, and priority can be specified in a cleaner way. This looks something like User.new.async(delay: 3).send(:notify_user) as opposed to the current User.new.async_send(:notify_user, :quebert => {delay: 3, pri: 1000})
  2. Quebert supports many back-ends: InProcess, Sync, and Beanstalk. Sync and InProcess were created to aid with testing assertions so that Quebert.backend.queue.should have(1).items is possible. It only needs Beanstalk, so the multiple-backends could be removed for the sake of simplicity. A stub could be provided for peeps that want to assert jobs are thrown on the queue in a test env.
  3. There's a controller layer between the Job and the Backend that communicates using exceptions, which is suppose to deal with multiple backends. Eww. I want to just pass a controller into the job and have it deal.

Backburner

View README.md

How we upgraded UserVoice, a Rails 2.3.14 app, to Ruby 1.9.3.

Blog post here: http://developer.uservoice.com/entries/how-to-upgrade-a-rails-2.3.14-app-to-ruby-1.9.3/
@bradgessler
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 'pollev.com', 'www.polleverywhere.com'
# 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'
end
@bradgessler
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
end
@bradgessler
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']) : Date.today - 90
# Blinksale username
@bradgessler
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
<?php
/*
Plugin Name: Posterous Importer
Plugin URI: http://wordpress.org/extend/plugins/posterous-importer/
Description: Import posts, comments, tags, and attachments from a Posterous.com blog.
Author: Automattic, Brian Colinger, Peter Westwood, Daryl L. L. Houston
Author URI: http://automattic.com/
Version: 0.10
License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@bradgessler
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](http://news.ycombinator.com/item?id=3737272) 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](http://community.active.com/blogs/productdev/2011/02/28/using-activerecord-3-without-rails) [with](http://exposinggotchas.blogspot.com/2011/02/activerecord-migrations-without-rails.html) [posts](https://github.com/thuss/standalone-migrations) 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
bradgessler / tell.sh
Created Feb 15, 2012
Say any URL on a Mac
View tell.sh
curl -s http://en.wikipedia.org/wiki/Rocket | sed -n -e 's/.*<p>\(.*\)<\/p>.*/\1/p' | sed -e "s/<[^>]*>//g" | say
@bradgessler
bradgessler / crash.rb
Created Sep 23, 2011
Fiber seg fault
View crash.rb
require 'rubygems'
require 'eventmachine'
require 'fiber'
EM.run{ Fiber.new{}.resume }
__END__
/Users/bgessler/Desktop/crash.rb:6: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
You can’t perform that action at this time.