Skip to content

Instantly share code, notes, and snippets.

require 'sinatra'
require 'open-uri'
require 'json'
OAUTH_URL = 'https://foursquare.com/oauth2'
BASE_URL = 'https://api.foursquare.com/v2'
REDIRECT_URI = 'http://localhost:9292/auth'
CLIENT_ID = 'YOUR_CLIENT_ID'
CLIENT_SECRET = 'YOUR_CLIENT_SECRET'
#spec/routing/pages_routing_spec.rb
require 'spec_helper'
describe 'routes to the pages controller' do
describe 'GET root_path' do
subject { {:get => root_path} }
it { should be_routable }
it { should route_to :controller => 'pages', :action => 'home' }
@yohfee
yohfee / zenra.rb
Created March 19, 2011 01:56
/lib/earthquake/commands.rbの"init"ブロック内に追記
command :zenra do |m|
require 'open-uri'
require 'rexml/document'
sentence = m[1]
appid = 'YOUR_YAHOO_APPID'
position = '動詞'
text = '全裸で'
base_url = 'http://jlp.yahooapis.jp/MAService/V1/parse'
@yohfee
yohfee / zenra.rb
Created March 22, 2011 01:28
~/.earthquake/plugin/zenra.rb
#coding: utf-8
require 'open-uri'
require 'rexml/document'
Earthquake.init do
config[:zenra] = {
:appid => 'YOUR_YAHOO_APPID',
:position => '動詞',
:text => '全裸で',
@yohfee
yohfee / notify.rb
Created March 23, 2011 07:11
~/.earthquake/plugin/notify.rb
#coding: utf-8
Earthquake.init do
config[:notify] = [/ruby/i, /#earthquake.gem/i]
output do |item|
next unless item["stream"]
if config[:notify].any?{|pattern| pattern =~ item["text"]}
notify item["text"], :title => item["user"]["screen_name"]
end
@yohfee
yohfee / icon.rb
Created March 30, 2011 01:08
~/.earthquake/plugin/icon.rb
#coding: utf-8
require 'open-uri'
require 'RMagick'
Earthquake.init do
command :icon do |m|
url = twitter.show(m[1])["profile_image_url"]
blob = open(url).read
image = Magick::Image.from_blob(blob).shift
@yohfee
yohfee / image.rb
Created March 30, 2011 01:59
~/.earthquake/plugin/image.rb
#coding: utf-8
require 'open-uri'
require 'RMagick'
Earthquake.init do
command :image do |m|
url = m[1]
blob = open(url).read
image = Magick::Image.from_blob(blob).shift
require 'mscorlib'
require 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
include System::Drawing
include System::Windows::Forms
class MyForm < Form
def initialize
button = Button.new
require 'mscorlib'
require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
include System::Net
include System::Text
include System::Windows::Forms
include System::Xml
class MyForm < Form
@yohfee
yohfee / awesome_print_mongoid.rb
Created May 18, 2011 09:35
Draft of awesome_print/lib/ap/mixin/mongoid.rb
module AwesomePrintMongoid
def self.included(base)
base.send :alias_method, :printable_without_mongoid, :printable
base.send :alias_method, :printable, :printable_with_mongoid
end
# Add Mongoid class names to the dispatcher pipeline.
#------------------------------------------------------------------------------
def printable_with_mongoid(object)