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
use strict; | |
use warnings; | |
use Test::More; | |
use resize; | |
subtest "valid case (with option)" => sub{ | |
my $valid_uri = "http://example.com/scale/c.120x240.sushi.png"; | |
my $file_info = resize::parse_uri($valid_uri); | |
is $file_info->{option}, "c", "option"; |
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
# -*- coding: utf-8 -*- | |
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib')) | |
require "net/http"require "uri" | |
require 'webantenna' | |
def usage | |
warn "usage: ruby main.rb imkayac_username imkayac_password" | |
exit 1 | |
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
precmd () { | |
psvar=() | |
psvar[1]=$(ruby -v | sed -e 's/ruby \([0-9]*.[0-9]*.[0-9]*\).*/\1/'); | |
} | |
PS1="[%1v]" |
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
PS1='`~/.current_rb_ver`' |
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
# -*- coding: utf-8 -*- | |
def nyan(nya,nn) | |
"#{nya}ーーー#{nn}!!#{nya}#{nn}#{nya}ーーーーーー#{nn}!!!!#{nya}#{nn}#{nya}#{nya}ーー#{nn}#{nya}#{nn}!!!#{nya}#{nn}#{nya}ー#{nn}!!!!#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}#{nya}ーーーー#{nn}!!!!!" | |
end | |
p nyan(*ARGV) |
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
# -*- coding: utf-8 -*- | |
require 'eventmachine' | |
require 'json' | |
require 'hashie' | |
#ログイン済みのコネクションハンドラーのコンテナ | |
class LoginedConnectionContainer | |
@@users = {} | |
def self.add(user_id,connection) |
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 "amqp" | |
AMQP.start(:host => "localhost") do |connection| | |
channel = AMQP::Channel.new(connection) | |
exchange = channel.direct("example") | |
room_id = ARGV.shift || "1" | |
message = ARGV.empty? ? "Hello World!" : ARGV.join(" ") | |
exchange.publish(message, :routing_key => room_id) | |
puts " [x] Sent #{room_id}:#{message}" |
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
use strict; | |
use warnings; | |
use Compress::Raw::Zlib; | |
my $file_name = shift; | |
my $opt_name = "glitched_".$file_name; | |
open (FH, $file_name) or die "$!"; | |
binmode FH; | |
my $hoge = *FH; |
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
package TwitterUser; | |
use strict; | |
use warnings; | |
# TwitterUser->new('シャークこすげ','9m'); を期待 | |
sub new{ | |
my ($class_name, $name, $screen_name) = @_; | |
warn $class_name; # => "TwitterUser" | |
warn $name; # => "シャークこすげ" | |
warn $screen_name; # => 9m |
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 :password, :user_id, :salt | |
has_many :articles | |
validates_presence_of :user_id, :password | |
def auth(password) | |
return self.password == password | |
end | |
end |