Skip to content

Instantly share code, notes, and snippets.

# This isn't as elegant as some of the other solutions for running multiple versions
# of Ruby but it's simple, straight-forward and has worked well for me so far. I'm
# currently running the most recent stable versions of 1.8.5, 1.8.6, 1.8.7, and
# 1.9.1 and plan to experiment with some patched versions as well.
# pull one of the tarballs down and extract:
$ cd /tmp
$ curl ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.gz |
tar xvzf -
$ cd ruby-1.9.1-p0
@gma
gma / gist:234446
Created November 14, 2009 08:43 — forked from jc00ke/gist:234265
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
module UserSpecHelper
def valid_user_attributes
{ :username => 'jc00ke',
:email => 'jc00ke@example.com',
:password => 'p@ssw0rd' }
end
def invalid_usernames
/* Multiget web service, written in Node
http://127.0.0.1:9001/?urls=http://example.com/,http://example.net/
Will fetch all URLs in parallel, then return a JSON response containing
the fetched content from them.
*/
var DEFAULT_TIMEOUT = 10000;
@gma
gma / app.rb
Created July 20, 2011 15:57
app.rb for legibilis
module Nesta
class App
get '/robots.txt' do
content_type 'text/plain', :charset => 'utf-8'
<<-EOF
# robots.txt
# See http://en.wikipedia.org/wiki/Robots_exclusion_standard
EOF
end
@gma
gma / soc-to-the-max.rb
Created July 17, 2012 09:55 — forked from rlivsey/soc-to-the-max.rb
Separation of concerns sketch
class TasksController < ApplicationController
def complete
# add responder as listener, or could subscribe etc...
# task could be the actual task, or pass through the ID
task.add_subscriber(TaskCompletedResponse.new(self))
task.add_subscriber(TaskEmail.new)
task.add_subscriber(TaskIndex)
task.complete_by(person)
end
@gma
gma / Gemfile
Created February 4, 2013 15:42 — forked from datenimperator/Gemfile
source 'http://rubygems.org'
gem 'nesta', '~> 0.9.13'
gem 'haml'
gem 'haml-coderay'
gem 'sass'
gem 'compass'
gem 'sprockets-sass'
<a href="//bufferapp.com/add" class="buffer-add-button" data-count="vertical">Buffer</a>
<script type="text/javascript" src="//d389zggrogs7qo.cloudfront.net/js/button.js"></script>
# https://www.agileplannerapp.com/blog/building-agile-planner/refactoring-with-hexagonal-rails
def checkout
cart = CartCheckout.new(many, params)
cart.save!
rescue OutOfStock => e
OutOfStockNotification.new(e.line_item).deliver
redirect_to cart_path, notice: t('.failure', reason: cart.error_message)
rescue CartError
redirect_to cart_path, notice: t('.failure', reason: cart.error_message)
else