Skip to content

Instantly share code, notes, and snippets.

@etrepat
etrepat / dsl.rb
Created July 4, 2011 13:39
Very simple unit testing framework (in ~44 lines)
class Dsl
def initialize
@tests = {}
end
def parse(description, block)
self.instance_eval(&block)
Executor.new(description, @tests)
end
def it(description, &block)
@tests[description] = block
@etrepat
etrepat / redis_pubsub_demo.rb
Created July 4, 2011 11:43 — forked from pietern/redis_pubsub_demo.rb
Simple demo to showcase Redis PubSub with EventMachine
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@etrepat
etrepat / criteria.rb
Created June 12, 2011 18:56 — forked from outoftime/criteria.rb
Instantiate the results of map-reduce operations as Mongoid documents
module Mongoid
class Criteria
include Criterion::MapReduce
end
end
@etrepat
etrepat / gist:1018500
Created June 10, 2011 08:51 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@etrepat
etrepat / example_gist_create.rb
Created November 11, 2010 16:42 — forked from schacon/example_gist_create.rb
Old gits api calls
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
@etrepat
etrepat / rails-install.sh
Created July 19, 2010 11:45
How to install ruby/rails dev. environment on Ubuntu 11.10
# Build-tools + Git
sudo apt-get install build-essential git-core
# Install required libraries & tools
sudo apt-get install bison openssl libreadline6 libreadline6-dev curl zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf
# -- SQLite3 support
sudo apt-get install libsqlite3-0 libsqlite3-dev sqlite3
# -- PostgreSQL support