Skip to content

Instantly share code, notes, and snippets.

@manveru
manveru / ramaze_snippet_finder.rb
Created March 23, 2011 11:18
Find random excerpts of code from Ramaze
require 'ramaze'
max = 40
final = []
Dir.glob("#{Ramaze::ROOT}/**/*.rb") do |path|
blocks = []
File.open path do |file|
block = []
@manveru
manveru / binding_of_caller.rb
Created March 22, 2011 07:57
Binding::of_caller for Rubinius
class Binding
def self.of_caller
bt = Rubinius::VM.backtrace(2, true).first
Binding.setup(
bt.variables,
bt.variables.method,
bt.static_scope
)
end
@manveru
manveru / bigcouch_compact.rb
Created March 14, 2011 04:09
compact bigcouch clusters
require 'makura'
require 'rye'
root = Makura::Server.new('http://host:5984')
nodes = root.membership['cluster_nodes']
p nodes: nodes
nodes.each do |node|
node_name = node[/@(\w+)/, 1]
puts "Connecting to #{node_name}"
@manveru
manveru / preview_couchdb_map.coffee
Created March 13, 2011 12:36
Preview behaviour of a map function over a subset of _all_docs.
http = require 'http'
p = console.log
options = {
host: 'kyle',
port: 5984,
path: '/tiny_cdr/_all_docs?include_docs=true&limit=100'
}
map_results = []
@manveru
manveru / dtmf.coffee
Created February 25, 2011 00:35
translate DTMF to digits
originalDTMF = {
0: 0,
1: 1, 2: 2, 3: 3,
4: 4, 5: 5, 6: 6,
7: 7, 8: 8, 9: 9,
a: 2, b: 2, c: 2,
d: 3, e: 3, f: 3,
g: 4, h: 4, i: 4,
j: 5, k: 5, l: 5,
@manveru
manveru / pong.nim
Created February 13, 2011 18:31
Pong in Nimrod
import math
import vector
import sdl
type
OBall = object
vector: TVector2
velocity: TVector2
radius: float
speed: float
@manveru
manveru / PKGBUILD
Created February 10, 2011 16:33
Fixed PKGBUILD for coffee-script-git
# Contributor: Stephen Diehl <sdiehl at clarku dot edu>
pkgname=coffee-script-git
pkgver=20110210
pkgrel=1
pkgdesc='CoffeeScript is a little language that compiles into JavaScript.'
arch=any
url=http://coffeescript.org
license=(custom)
makedepends=(nodejs)
md5sums=()
@manveru
manveru / pluralize.rb
Created January 25, 2011 19:12
simple pluralization framework
module Pluralize
module_function
def pluralize(string)
string = string.dup
@plural.each do |pattern, options|
string.gsub!(pattern, options[:replace])
end
@manveru
manveru / start.rb
Created January 25, 2011 15:47
Generate static pages in Ramaze
require 'ramaze'
class Main < Ramaze::Controller
def index
make_static
end
private
def make_static
@manveru
manveru / beats.scm
Created January 23, 2011 20:50
Display Internet Time in Chicken Scheme.
(use posix format)
(setenv "TZ" "UTC-1")
(let ((tl (seconds->local-time (current-seconds))))
(format #t "@~,2F~%" (+ (* (vector-ref tl 2) (/ 1000 24))
(* (vector-ref tl 1) (/ 1000 24 60))
(* (vector-ref tl 0) (/ 1000 24 60 60)))))