Skip to content

Instantly share code, notes, and snippets.

# aldershot.rb
=begin
main file for aldershot mountain.
aldershot mountain is/will be a (currently)
simple chutes and ladders/snakes and
ladder/adders and ladders/moksha patamu/
gyanbazi/leela ripoff.
=end
@tamalw
tamalw / gist:2490
Created July 25, 2008 18:36
Messing around at ShoesFest!
# The goal is to have all the words on one line, with "shoes" bold, larger, and a different color
Shoes.app do
background black
# Looks okay
flow do
subtitle "I want new ",
strong("shoes", :stroke => chocolate),
@tamalw
tamalw / tweet_beat.rb
Created July 25, 2008 22:10
Watch your keywords appear on the twitter stream
#
# tweet_beat.rb
# ShoesFest 2008
#
# Created by Tamal White on 2008-07-25.
# Copyright 2008 Tamal White. All rights reserved.
#
require 'hpricot'
require 'date'
class DateTime
def to_f
days_since_unix_epoch = self - ::DateTime.civil(1970)
(days_since_unix_epoch * 86_400).to_f
end
end
foo = DateTime.now
#!/bin.bash
regex='^[0-9]+$'
foo='1234'
bar='hi bean'
echo "foo = $foo"
if [[ "$foo" =~ $regex ]]; then
@tamalw
tamalw / time_tz_monkeypatch.rb
Created August 14, 2008 17:54
Get the time in another timezone
require 'time'
class Time
def in(tz)
current_tz = ENV["TZ"]
ENV["TZ"] = tz
new_time = self.getutc.getlocal
ENV["TZ"] = current_tz
new_time
end
# Models
class Agent < ActiveRecord::Base
belongs_to :manager
belongs_to :site
belongs_to :workgroup
end
class Manager < ActiveRecord::Base
has_many :agents
#!/usr/bin/ruby
require 'rubygems'
require 'net/http'
require 'hpricot'
class Twitter
def initialize(username, password)
#!/usr/bin/env ruby
# Written by @tamalw for @jasonfried (http://twitter.com/jasonfried/status/1177797820)
# Portions of the Twitter class borrowed from @hagus (http://gist.github.com/41922)
require 'rubygems'
require 'net/http'
require 'hpricot'
class Twitter
@tamalw
tamalw / hi.rb
Created November 20, 2009 17:13
require 'rubygems'
require 'sinatra'
require 'rack/utils'
@@datastore = []
get '/' do
if params[:t]
@@datastore.unshift(Rack::Utils.unescape(params[:t]))
"a"