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
View csv_definition.rb
require "csv"
class CSVDefinition
attr_reader :definition
def initialize
@definition ||= Hash.new
end
def row(name, &block)
View OEmbed Discovery
<html>
<head>
<link rel="alternate" type="application/json+oembed" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DGvxCi06sc2I&format=json" title="Dancing Girls! (10-16-09 Vlog #5)" />
<link rel="alternate" type="text/xml+oembed" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3DGvxCi06sc2I&format=xml" title="Dancing Girls! (10-16-09 Vlog #5)" />
[...]
</head>
<body>
[...]
</body>
</html>
@bradgessler
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 https://github.com/rails/rails/issues/9940.
Rails.application.config.middleware.use RewriteIEAcceptHeader do |ie_mime_types|
@bradgessler
bradgessler / docker.sh
Created Nov 15, 2016
First CLI commands
View docker.sh
$ docker run ubuntu /bin/echo 'Hello world'
Hello world
@bradgessler
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 http://bradgessler.com/articles/hon/
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
bradgessler / doc.erb.bd
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.
View doc.erb.bd
# How to tie your shoes
<%= toc.each do |id, text| %>
* [<%= text %>](#<%= id %>)
<% end %>
## Unlace them
Gotta make sure its untied before you tie it!
@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/
You can’t perform that action at this time.