Skip to content

Instantly share code, notes, and snippets.

View mguterl's full-sized avatar

Mike Guterl mguterl

View GitHub Profile
@wycats
wycats / 0_app.rb
Created April 19, 2012 10:22
Example of using a simple future library for parallel HTTP requests
class TicketsController < ApplicationController
def show
tickets = params[:tickets].split(",")
ticket_data = tickets.map do |ticket|
parallel { Faraday.get("http://tickets.local/#{ticket}") }
end
render json: { tickets: ticket_data.map(&:result) }
end
@jimweirich
jimweirich / abstract.md
Created April 17, 2012 23:53
Berlin Clock Kata

Berlin Clock

Original Reference

Create a representation of the Berlin Clock for a given time (hh::mm:ss).

The Berlin Uhr (Clock) is a rather strange way to show the time. On the top of the clock there is a yellow lamp that blinks on/off every two seconds. The time is calculated by adding rectangular lamps.

@ahoward
ahoward / conducer.rb
Created April 10, 2012 19:22
sketching out a high level explanation of dao's conducer: presenter X conductor
# -*- encoding : utf-8 -*-
#
# conducers combine the presenter pattern with the conductor pattern. they
# can present and conduct an arbitrary number of models. they can also unify
# models with api calls and other non-persisted data in way that supports
# restufl interfaces, validations, form helpers, etc. consider conducers and
# being 'conductive to' writing web applications: you can prepare arbirtray
# data for the view and serialize arbirtray data out of it into a data store.
#
# to your controllers and views a conducer looks *just like a model* except
@coreyhaines
coreyhaines / .rspec
Last active August 15, 2024 15:13
Active Record Spec Helper - Loading just active record
--colour
-I app
class Scanner
def initialize(display)
@display = display
end
def scan
@display.last_item = Item.new("Cornflakes")
end
end
Item = Struct.new(:name)
@ahoward
ahoward / _flash.html.erb
Created March 3, 2012 16:22
portable templates. in rails and js.
<%
unless @flash_has_already_been_rendered
flash = self.flash ### see http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/8e54e4bc3c2b4366
keys = flash_message_keys
javascript = []
unless flash[:hide]
keys.each do |key|
~/Code/ember.js ‹ruby-1.9.3› ‹master*› $ bundle && echo "fuck you giles"
Using rake (0.9.2.2)
Using confparser (0.0.2.1)
Using multi_json (1.0.4)
Using execjs (1.2.13)
Using libxml-ruby (2.2.2)
Using faster_xml_simple (0.5.0)
Using httpclient (2.2.4)
Using json (1.6.5)
Using nokogiri (1.5.0)
@ahoward
ahoward / presenter.rb
Created February 22, 2012 23:09
worlds simplest presenter pattern. drop in replacement for ActiveRecord/Mongoid models in your controller
# the worlds lightest weight presenter pattern. to use simply
#
# file app/presenters/post_presenter.rb
#
# PostPresenter =
# Presenter.for(Post) do
# validates_presence_of :custom_field_for_this_form
#
# end
#
@nofxx
nofxx / resque.rake
Created February 9, 2012 10:25
Resque syslog (via log4r)
require 'log4r'
require 'log4r/outputter/syslogoutputter'
require 'resque/failure/multiple'
require 'resque/failure/redis'
module Resque
module Failure
class Syslog < Base
# Define your logger, change as needed.
@mislav
mislav / stupid-json.rb
Created December 21, 2011 12:31
Stupid simple JSON parser & generator
# encoding: utf-8
#
## Stupid small pure Ruby JSON parser & generator.
#
# Copyright © 2013 Mislav Marohnić
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the “Software”), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to