- BINARY な文字列を使うときだけ
force_encoding
しなさい。 - ネットワークかファイルシステムから BINARY な文字列を受け取ったとき
は、確実に正しいエンコーディングに
force_encode
しなさい。- 一般的に、HTTP における Content-Type ヘッダのようなもので ネットワークから受け取った BINARY な文字列のエンコーディング 情報は与えられている。
- エンーコーディングがわからないときは、その文字列はずっと BINARY で扱いなさい。BINARY でない文字列との結合なんてし
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
# Church numerals | |
zero = lambda{|f| | |
lambda{|x| x } | |
} | |
one = lambda{|f| | |
lambda{|x| | |
f.call(x) | |
} | |
} |
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
diff --git a/lib/gettext/core_ext/string.rb b/lib/gettext/core_ext/string.rb | |
index fa8149c..9eb6d51 100644 | |
--- a/lib/gettext/core_ext/string.rb | |
+++ b/lib/gettext/core_ext/string.rb | |
@@ -64,6 +64,7 @@ class String | |
args.has_key?(key) ? sprintf("%#{$3}", args[key]) : match | |
end | |
} | |
+ ret | |
else |
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 'rubygems' | |
require 'rack' | |
module Rack | |
class Analog | |
ANALOG =<<-HTML | |
<div style="position:absolute;top:0;right:0;border:solid;width:5%;"> | |
アナログ | |
</div> |
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 'rack' | |
require 'activerecord' | |
require 'erb' | |
class LineBbs | |
include ERB::Util | |
def call(env) | |
request = Rack::Request.new(env) |
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 Stack | |
class EmptyError < StandardError | |
end | |
class Node | |
attr_accessor :prev, :data | |
def initialize(prev, data) | |
@prev = prev |
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
#!/bin/sh | |
for rev in 5 6 7 | |
do | |
cd $HOME/src/all-ruby/ruby_1_8_${rev} | |
autoconf | |
./configure --prefix=$HOME/all-ruby/ruby18${rev} \ | |
--disable-install-doc \ | |
--enable-pthread \ | |
#--with-X11-include=/usr/include/X11/ \ |
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
diff --git a/lib/plugins/notify-send.rb b/lib/plugins/notify-send.rb | |
index 834fa82..4713a8c 100644 | |
--- a/lib/plugins/notify-send.rb | |
+++ b/lib/plugins/notify-send.rb | |
@@ -15,7 +15,7 @@ Termtter::Client.register_hook( | |
text << %Q|\n<a href="http://twitter.com/">more...</a>| if statuses.size > max | |
- system 'notify-send', '-t', '60000', '--', 'Termtter', text | |
+ system 'notify-send', '-t', '60000', '--', 'Termtter', text unless text.empty? |
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
diff --git a/lib/plugins/defaults/retweet.rb b/lib/plugins/defaults/retweet.rb | |
index b2db68d..e07d152 100644 | |
--- a/lib/plugins/defaults/retweet.rb | |
+++ b/lib/plugins/defaults/retweet.rb | |
@@ -33,6 +33,7 @@ module Termtter::Client | |
comment += ' ' unless comment.nil? | |
rt_or_qt = (config.plugins.retweet.quotetweet and comment) ? 'QT' : 'RT' | |
text = ERB.new(config.plugins.retweet.format).result(binding) | |
+ get_hooks(:modify_status_for_retweet).each{|hook| text = hook.call(text) || '' } | |
Termtter::API.twitter.update(text) |
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
ruby 1.8.0 (2003-08-04) [x86_64-linux] | |
Rehearsal --------------------------------------------- | |
return 0.416667 0.000000 0.416667 ( 0.254624) | |
no return 0.316667 0.000000 0.316667 ( 0.185749) | |
return 0.433333 0.000000 0.433333 ( 0.264098) | |
no return 0.383333 0.000000 0.383333 ( 0.224070) | |
------------------------------------ total: 1.550000sec | |
user system total real | |
return 0.366667 0.000000 0.366667 ( 0.226396) |
OlderNewer