Skip to content

Instantly share code, notes, and snippets.

View damon's full-sized avatar

Damon Clinkscales damon

View GitHub Profile
@damon
damon / Gemfile
Created August 17, 2010 15:28 — forked from pengwynn/Gemfile
source :rubygems
gem 'sinatra', '1.0'
gem 'gowalla', '~> 0.2.0'
group :development do
gem 'shotgun'
end
javascript:document.querySelector("meta[name='viewport']").setAttribute("content", "width=device-width; initial-scale=1.0; maximum-scale=5.0; user-scalable=1;");
require "time"
class BusinessHours
DAYS = [:sun, :mon, :tue, :wed, :thu, :fri, :sat]
def initialize(opening, closing)
@schedule = { :default => [opening, closing] }
end
def update(day, opening, closing)
require 'rubygems'
require 'yajl/http_stream'
require 'uri'
require 'open-uri'
USERNAME = 'username'
PASSWORD = 'password'
# If you've got a ton of either, you'll have to fork and cursor through
fr_ids = Yajl::HttpStream.get(URI.parse("http://#{USERNAME}:#{PASSWORD}@api.twitter.com/1/friends/ids/#{USERNAME}.json"))
module Kernel
def m(object=Object.new, pattern=nil)
methods = object.public_methods(false).sort
methods = methods.grep pattern unless pattern.nil?
ObjectMethods.new(methods)
end
class ObjectMethods < Array
def inspect
puts sort
# Put this in your .irbrc, and then type
# "some_object.my_methods" in an IRB session
# for less noisy exploration of what objects
# can do.
class Object
def my_methods
base_object = case self
when Class then Class.new
when Module then Module.new
@damon
damon / json_hax.rb
Created January 6, 2010 22:09 — forked from tobi/json_hax.rb
class JsonHax
def initialize(app)
@app = app
end
def call(env)
if env['CONTENT_TYPE'] == 'application/json'
env['CONTENT_TYPE'] = 'application/xml'
env['REQUEST_URI'].gsub!(/\.json/, '.xml')
@damon
damon / url_dsl.rb
Created December 14, 2009 16:19 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
We couldn’t find that file to show.
@damon
damon / 0what.md
Created August 24, 2009 02:32 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?