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
# -*- coding: utf-8 -*- | |
# Memento Pattern | |
# original code from wikipedia | |
# http://ja.wikipedia.org/wiki/Memento_パターン | |
class Originator | |
attr_reader :state | |
def initialize |
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
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'sinatra' | |
require 'json' | |
get '/' do | |
text = JSON.parse(params[:json])['events'][0]['message']['text'] | |
NiseHarizon.say if NiseHarizon.yharian?(text) | |
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
Spec::Matchers.create :be_same_list do |other| | |
match do |me| | |
me.sort == other.sort | |
end | |
end | |
[1, 2, 3, 4].should be_same_list([2, 1 ,4, 3]) | |
[1, 2, 3, 4].should_not be_same_list([2, 4, 3]) |
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
# Tag for group | |
def tag(name) | |
[ | |
[:friends, 'F'], | |
[:hacobu, 'H'], | |
[:etc, 'E'], | |
[:czcc, 'C'], | |
[:ruby, 'R'], |
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 Termtter | |
class AwesomePlugin < Plugin | |
desc 'say awesome easily' | |
help = ['awesome [USERNAME]', 'say awesome'] | |
register_command(:awesome, :help => help) do |user| | |
if user.empty? | |
call_commands('u Awesome!') | |
else |
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 << ( | |
class Klass | |
def hi | |
p 'hi from instance' | |
end | |
self | |
end) | |
def hi |
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
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'mechanize' | |
def google(query) | |
agent = WWW::Mechanize.new | |
agent.get 'http://www.google.com' | |
agent.page.form_with(:name => 'f') do |form| | |
form.field_with(:name => 'q').value = query |
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
# via http://twitter.com/mootoh/statuses/6530680695 | |
class Object | |
def now | |
require 'net/http' | |
require 'uri' | |
res = Net::HTTP.post_form( | |
URI.parse('http://USERNAME:[email protected]/statuses/update.json'), | |
{:status => self.inspect.split(//).take(140).join}) | |
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
diff --git a/lib/rubytter.rb b/lib/rubytter.rb | |
index 0447f76..220922f 100644 | |
--- a/lib/rubytter.rb | |
+++ b/lib/rubytter.rb | |
@@ -55,7 +55,7 @@ class Rubytter | |
friendship_exists /friendships/exists | |
followers_ids /followers/ids/%s | |
friends_ids /friends/ids/%s | |
- favorites /favorites | |
+ favorites /favorites/%s |
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
// Usuko original by Kanasansoft | |
jetpack.tabs.onReady(function (doc) { | |
if (doc.defaultView.frameElement) { return; } | |
var display = function () { | |
var IMAGE_URI_USUKO = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAYAAAB1ovlvAAAAAXNSR0IArs4c6QAAIABJREFUeNrsvXmwbWlVJ%2Fhb6xv2cIZ735AvB0gy04RGyFRAKKOkEVEDi0I7UNvq7lK0caimjNbAQolqDbu7IqwqNcqysC0HFBwRowUbS1FAxAkQJZMhwYSEJMnxZb7MN9zxnLP3%2FobVf3zfPufc%2B%2B6bMvO9fJl5d8SNO517zrl7%2F%2FYafuu31gL2j%2F1j%2F9g%2F9o%2F9Y%2F%2FYP%2FaP%2FWP%2F2D%2F2j%2F3j6XKo%2FVNw2Rz0dLwe%2BwC8uAdnYJ0vAPeP%2FeNxt2r7x74FfEItYH%2BOZR%2Bspx96HyMXzfIV%2BWt%2FDvBRvg7LQJX8d3EfgE9vEPWJgQZg8mcGEAC0GSTLhyxZPr0LfHQGIPZgC2d4rjO9LzkPq7oPwCdhSGIBVABqACMAqwAOLn1UGXwPATgJwGUgxKXPvfXqv95eAmz%2F0S19vRtMdA5wcf4cnuwg3A%2BSF6AbAjgC4FoAz8pfHwFwOH8%2BCOBAfmwAcArA%2BhKQugw4lz%2Ba%2FLgGwAaACYBZ%2FtgGsAbgOIATADbz4%2FwSqM7ltp8SVvDpCkDKLnUM4GoA1wP47%2FLHDQCuytavzLFcseSG%2ByPuAovfBYqQP9wuULoMxk0ADwI4CuABAA9nMJ7MwF62mvJUvhBPx%2BTgKgAvAPAyAF8F4Jrsauv8e7Xr3NCS2zvTIWc4n7ILtLIE3gbAVraQpzL4Hsg |