Skip to content

Instantly share code, notes, and snippets.

@tkareine
tkareine / count_down_latch.rb
Created December 13, 2010 21:56
A simple count down latch in Ruby
#!/usr/bin/env ruby
# coding: utf-8
require 'thread'
class CountDownLatch
attr_reader :count
def initialize(to)
@count = to.to_i
@fnando
fnando / message.rb
Created January 28, 2011 21:26
Fluent interfaces + blocks example
class Message
def initialize(&block)
instance_eval(&block) if block_given?
end
def to(name)
@to = name
self
end
@fnando
fnando / rubygems_proxy.rb
Created April 28, 2011 22:54
Rack app for caching RubyGems files. Very useful in our build server that sometimes fails due to our network or rubygems.org timeout.
# Moved to its own repo: http://github.com/fnando/rubygems_proxy
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@guilhermesilveira
guilhermesilveira / gist:2215876
Created March 27, 2012 13:30
monad lists, o basico do map
package br.com.caelum.example.monad;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
interface Monad<A> {
<B> Monad<B> map(Function<A, B> f);
}
@alloy
alloy / 1-README.md
Created July 5, 2012 16:01
RubyMotion MacBacon UI layer spec.
@asabaylus
asabaylus / gist:3071099
Created July 8, 2012 14:12
Github Markdown Heading Anchors

Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@josevalim
josevalim / 0_README.md
Created September 13, 2012 21:52
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

class Foo
include Module.new {
def this_works
end
}
include Module.new do
def this_doesnt_work
end
end