This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source :rubygems | |
| gem 'sinatra', '1.0' | |
| gem 'gowalla', '~> 0.2.0' | |
| group :development do | |
| gem 'shotgun' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:document.querySelector("meta[name='viewport']").setAttribute("content", "width=device-width; initial-scale=1.0; maximum-scale=5.0; user-scalable=1;"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
NewerOlder