Skip to content

Instantly share code, notes, and snippets.

View onewland's full-sized avatar

Oliver Newland onewland

  • San Francisco, CA
View GitHub Profile
function TimeInterval() {
this.seconds = 0;
this.addTo = function(ti) {
this.seconds += ti.seconds;
return this;
}
}
@onewland
onewland / cron-test.js
Created November 18, 2009 03:19
simple cron API for node.js
var cron = require('./cron'), sys = require('sys');
cron.Every((2).seconds(), function() { sys.puts('Working!'); });
@onewland
onewland / cron-test.js
Created November 18, 2009 21:35 — forked from fwg/cron-test.js
corrected cron.js
// Sample for http://oliveriskindoffunny.tumblr.com/post/247975858/implementing-a-user-friendly-cron-module-with-node-js
var cron = require('./cron'), sys = require('sys');
cron.Every((2).seconds(), function() { sys.puts('Working!'); });
#!/usr/bin/ruby
latest_migration = Dir.entries('db/migrate/').select{ |fname| fname =~ /^\d{14}/ }.sort.last
exec "$EDITOR db/migrate/#{latest_migration}"
if condition
result
end
# result can be any type, condition can be any type; anything that's not false or nil is considered true
require 'rubygems'
require File.join( File.dirname(__FILE__), '..', 'lib', 'carmen_sandiego.rb' )
detective = CarmenSandiego::Detective.new('GeoAPI API Key')
results = detective.search do |q|
q.radius 500
q.radius_unit :m
q.lat 27.93547
q.lng -82.50429
@onewland
onewland / .vimrc
Created September 25, 2010 17:05
au FileType c set ts=4
au FileType c set shiftwidth=4
au FileType ruby set expandtab
au FileType ruby set shiftwidth=2
# Never Again.
def link_tree(location, options=nil)
return "" unless location
options ||= {}
max_depth = options[:max_depth] || 5
partial = options[:partial] || "shared/location_subtree"
loc_tree = []
max_depth.times do
loc_tree << {}
@onewland
onewland / strstr.rb
Created December 6, 2010 16:27 — forked from rachelmyers/strstr
def substring(haystack, needle)
0.upto(haystack.length) do |i|
return i if haystack[i,(needle.length)] == needle
end
return nil
end
puts substring("stupid", "smart")
puts substring("stupid", "stu")
puts substring("stupid", "pid")
@onewland
onewland / testq.rb
Created May 16, 2011 22:09
Last question
class Cylinder
def initialize(r,h)
@r = r
@h = h
end
def volume
pi * r * r * h
end
end