Skip to content

Instantly share code, notes, and snippets.

module CouchRest
class Database
attr_accessor :name, :server
def initialize(server, database_name)
@name = database_name
@server = server
end
def documents(params=nil)
~ % ruby hash.rb
"foo"
nil
hash.rb:9:in `[]': PythonLike (PythonLike)
from hash.rb:14
@sr
sr / a.rb
Created September 2, 2008 20:31
class Hash
def stringify_keys!
keys.each do |key|
self[key.to_s] = delete(key)
end
self
end
def jsonify_necessary_values!
values.each do |key, value|
19:57 <sha1> http://pastie.org/281547 .. why is this weird thing happenning?
19:58 <elliottcable> one-upped!
19:58 <elliottcable> Grr apeiros can you voice me on #Ruby-Pro just so I can change nicks without leaving it?
19:59 <_rane> #ruby-pro? is that were all the elitists dwell?
19:59 <_rane> where*
19:59 <elliottcable> _rane: Apperantly so.
19:59 <elliottcable> I'd think that'd be *any* Ruby channel, but meh.
20:00 <wmoxam> lol
20:00 <wmoxam> #ruby-pro
20:00 -!- dug [n=doug@c-24-130-242-180.hsd1.ca.comcast.net] has quit [Read error: 110 (Connection timed out)]
@sr
sr / post.js
Created October 30, 2008 00:05
function(doc) {
if ( doc.type == "collection" ) {
emit([doc._id, 0], doc);
} else if ( doc.type == "entry" ) {
emit([doc.collection, 1, doc.edited], doc);
}
}
require 'linahi' # this is just my app, which seems to work ok
require 'sinatra/test/spec'
context 'Linahi' do
specify 'should list files when asked' do
get_it '/'
puts body
end
require 'rubygems'
require 'grit'
%w(saloon config couchy dst dumbapp git-wiki integrity).each do |repository|
repo = Grit::Repo.new(File.expand_path("~/code/#{repository}"))
commits = repo.log.collect { |commit| commit.message }
total_commits = commits.length.to_f
cosmetic_commits = commits.select { |message| message =~ /cosmetic/ }.length.to_f
require 'rubygems'
require 'open-uri'
require File.dirname(__FILE__) + '/gchartrb/lib/gchartrb'
def get_chart(color, data)
chart = GoogleChart::PieChart.new
chart.width = 600
chart.height = 300
total = data.inject(0) { |sum, (label, value)| sum = sum + value }
@sr
sr / sinatra-apps.txt
Created November 4, 2008 17:39
let's make a list of sinatra-based apps
The list is now managed directly in Sinatra's website.
<http://www.sinatrarb.com/wild.html>
=begin
Shooter
<http://gist.github.com/25886>
Harry Vangberg <http://trueaffection.net>
Simon Rozet <http://purl.org/net/sr/>
EXAMPLE
IRC.shoot('irc://irc.freenode.net:6667/integrity', :as => "IntegrityBot") do |channel|