Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("mongoid_before_create")
end
Mongoid.master.collection("topics").drop
Mongoid.master.collection("members").drop
Mongoid.master.collection("posts").drop
@chatgris
chatgris / async.coffee
Created July 18, 2011 23:14 — forked from tcr/async.coffee
Serial/Parallel functions in CoffeeScript
# Asynchronous DSL for CoffeeScript
serial = (f) ->
next = -> arr.shift().apply(null, arguments) if arr.length
arr = (v for k, v of f(next))
next()
null
parallel = (f, after = ->) ->
res = {}; arrc = 0
@chatgris
chatgris / incrudable.rb
Created July 30, 2011 09:45 — forked from rbxbx/incrudable.rb
CRUD with decent_exposure
# pulled out of a project authored by tpope && rbxbx
# not generic enough for general use, but a decent example of
# an application specific restful crud abstraction
module Incrudable
extend ActiveSupport::Concern
included do
expose(controller_name) { controller_name.classify.constantize.scoped }
expose(controller_name.singularize)
@chatgris
chatgris / Gemfile
Created March 10, 2012 17:57
Playing with Sinatra streaming api.
source :rubygems
gem 'sinatra', git: 'git://github.com/sinatra/sinatra.git'
gem 'thin'
@chatgris
chatgris / Gemfile
Created October 18, 2012 15:02
Stack powered by celluloid and zmq
source :rubygems
gem 'celluloid-zmq', github: "chatgris/celluloid-zmq", branch: "more_parts"
Earthquake.init do
output do |item|
if item["text"] || item["retweeted_status"]
matches = item['retweeted_status'].nil? ?
URI.extract(item["text"],["http", "https"]) :
URI.extract(item['retweeted_status']["text"],["http", "https"])
matches.each do |match_url|
browse match_url
end
end