Skip to content

Instantly share code, notes, and snippets.

View mattly's full-sized avatar
💭
I may be slow to respond.

Matthew Lyon mattly

💭
I may be slow to respond.
View GitHub Profile
@mattly
mattly / gist:4933
Created August 11, 2008 20:19 — forked from mmower/gist:4932
def note_to_freq( note_num )
base_note_num = note_num - 69
440.0 * Math.exp( 0.057762265 * ( note_num - 69 ) )
end
60.upto(72) {|n| puts note_to_freq(n) / note_to_freq(60) }
1.0
1.05946309430986 # 61, C#
1.12246204820462 # 62, D
1.18920711483625 # 63, D#
@mattly
mattly / profile.rb
Created October 20, 2008 06:52
profile of max<>ruby vs pure ruby scheduling
require 'rubygems'
require 'datagrammer'
require 'statarray'
deltas = StatArray.new
ticks = StatArray.new
d = Datagrammer.new(5000)
last = Time.now.to_f
last_tick = 0
d.listen do |slf, msg|
# = rCouch (working title)
# a system for working with couchdb documents that works similar to jquery
Collection.new(@db, {})
Collection.new(@db, [{}, {}])
# creates a collection of documents
# == Retrieving from the Database
# Single Document GET, for when you know the id
Autosaver = function(formele, options) {
var form = $(formele);
var settings = $.extend({
checkDirtyTime: 2000,
saveTime: 15000,
statusEle: '.save-status',
serialize: function(observing) {
var elements = $('[name=]', form);
if (observing) { elements = elements.not('[name=_rev],[name=_id]'); }
return elements.serialize();
# todo: add handlers for erb blocks
# example:
# - content_for :head do
# :javascript
# var foo = "foobar"
# and then in where you want that:
# = content_for :head
def content_for bin, content=nil, &block
class Time
# because i often times have trouble keeping these straight
# >> 1.day.ago.before? Time.now
# => true
# >> 1.day.from_now.before? Time.now
# => false
# >> 1.day.from_now.after? Time.now
# => true
# >> 1.day.ago.after? Time.now
mattly@Selene ~clients/[redacted]/[redacted] git:master > rake spec
(in /Users/mattly/clients/[redacted]/[redacted])
spec/spec_helper.rb:12
require 'rspec_on_rails_on_crack'
(rdb:1) p Spec::VERSION::SUMMARY
"rspec 1.2.4"
# FAIL!
module TaskList
def self.included(base)
base.extend Events
base.send :include, Events
end
module Events
def events
@events ||= Hash.new {|h,k| h[k] = []}
class Site
include Exegesis::Database
design :pages do
docs :by_state
docs :for_path
def at_path(path='')
for_path([path, ''..'ZZZZ'])[path]
end
end
describe MyApp do
include Sinatra::Test
before do
@app = MyApp
setup_site
setup_user
end
describe "when logged in" do