This file contains 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 Foo | |
def bar | |
puts "bar" | |
end | |
end | |
class Hoge | |
include Foo | |
def bar | |
puts "hoge" |
This file contains 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 "bundler/setup" | |
require "tapp" | |
class Regexp | |
def self.build(*numbers) | |
nums = [] | |
numbers.each do |num| | |
if num.is_a? Range | |
nums.concat(num.to_a) |
This file contains 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 Fixnum | |
def to_roman | |
return "" unless (1..3999).include?(self) | |
digit_count = Math.log(self, 10).to_i | |
case digit_count | |
when 0 | |
minor = "I" | |
major = "V" |
This file contains 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 "https://rubygems.org" | |
gem "actionpack" | |
gem "rype" | |
gem "awesome_print" | |
gem "simple-rss" |
This file contains 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
import System.Environment | |
import System.Random | |
import Control.Monad | |
import Data.List | |
import Data.List.Split | |
data Amida = Amida { amidaRow :: Int, amidaCol :: Int, amidaMap :: [[Bool]] } deriving (Show) | |
main :: IO () | |
main = do (r:c:[]) <- getArgs |
This file contains 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
import System.Environment | |
main :: IO() | |
main = do a <- getArgs | |
putStrLn $ digitToEng $ read $ head a | |
digitToEng :: Int -> String | |
digitToEng n | |
| n == 0 = "zero" | |
| n == 1 = "one" |
This file contains 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
Earthquake.init do | |
output do |item| | |
next unless item["_stream"] && item["user"] | |
if item["user"]["screen_name"] =~ /usagee_audio/i | |
notify item["text"], :title => "#{item["user"]["screen_name"]}" | |
end | |
end | |
end |
This file contains 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 User < ActiveRecord::Base | |
attr_accessible :image, :name, :provider, :screen_name, :uid | |
def self.find_or_create_with_omniauth(auth) | |
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) | |
unless user | |
user = User.new | |
user[:provider] = auth["provider"] | |
user[:uid] = auth["uid"] |
This file contains 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 SessionsController < ApplicationController | |
def callback | |
auth = request.env["omniauth.auth"] | |
user = User.find_or_create_with_omniauth(auth) | |
session[:user_id] = user.id | |
redirect_to posts_url, :notice => "Signed in!" | |
end | |
def failure | |
end |
This file contains 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
<h1>Listing posts</h1> | |
<% if current_user %> | |
login user: <%= current_user.screen_name %> | |
<% end %> | |
<table> | |
<tr> | |
<th>Title</th> | |
<th>Body</th> | |
<th></th> |