Skip to content

Instantly share code, notes, and snippets.

View sorah's full-sized avatar

Sorah Fukumori sorah

View GitHub Profile
@sorah
sorah / a.rb
Created February 28, 2014 02:23
class Foo
def initialize
@hooks = []
@methods = {}
@existing_methods = self.methods
end
def add(mode=nil, &block)
@hooks << block
end
@sorah
sorah / a.md
Last active August 29, 2015 13:56

Commits around degrade in rails/rails#14188 https://bugs.ruby-lang.org/issues/9223


  • r44137: Change to use rb_hash_new. Extra states won't be copied after this change.
  • r44247: Add constant to switch behavior. Prepare to show warnings. (HASH_REJECT_COPY_MISC_ATTRIBUTES)
  • r44250: Fix constant name differs in ifdef, which introduced at previous commit (r44247) (HASH_REJECT_COPY_MISC_ATTRIBUTES)
  • r44262: Show warnings when --verbose is enabled. (HASH_REJECT_COPY_MISC_ATTRIBUTES)
  • r44263: Revert to 2.0.0 behavior (copy misc attributes) by set HASH_REJECT_COPY_MISC_ATTRIBUTES to 1.
  • (Ruby 2.1.0 release branch has
@sorah
sorah / relink.sh
Last active August 29, 2015 13:57
homebrew: link missing LinkedKegs again
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 2e3c2ae..f478e11 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -660,6 +660,7 @@ class TestMethod < Test::Unit::TestCase
assert_equal(__dir__, eval("__dir__", binding), bug8436)
bug8662 = '[ruby-core:56099] [Bug #8662]'
assert_equal("arbitrary", eval("__dir__", binding, "arbitrary/file.rb"), bug8662)
+ assert_equal("arbitrary", Object.new.instance_eval("__dir__", "arbitrary/file.rb"), bug8662)
end
@sorah
sorah / zabbix2idobata.sh
Created March 27, 2014 19:52
zabbix -> idobata
# Set the following script to "Actions -> Operations -> Remote command (target: current host, execute on: zabbix server)"
# http://img.sorah.jp/z-20140328-045035.png
# ruby is required
bash <<'EOF'
YOUR_ZABBIX_DOMAIN="zabbix"
IDOBATA_HOOK="http://idobata.io/hooks/XXX"
LABEL="$(ruby -e'puts %w(default inverse warning important important important)[ARGV[0].to_i]' -- {TRIGGER.NSEVERITY})"
[ "_{TRIGGER.STATUS}" = "_OK" ] && LABEL="success"
@sorah
sorah / anime-2014-spring.md
Last active August 29, 2015 13:57
アニメ 2014 年春期 (4月-7月)

未ソート

4/11(金) 25:35- TOKYO MX | デート・ア・ライブ http://date-a-live-anime.com/
4/12(土) 27:00- BS11     | デート・ア・ライブ http://date-a-live-anime.com/
4/12(土) 24:00- TOKYO MX | メカクシティアクターズ http://www.mekakucityactors.com/
4/12(土) 24:00- BS11     | メカクシティアクターズ http://www.mekakucityactors.com/
4/21(月) 25:35- TOKYO MX | M3-ソノ黒キ鋼- http://m3-project.com/
4/21(月) 25:35- TOKYO MX | M3-ソノ黒キ鋼- http://m3-project.com/
4/03(木) 26:16- TBS      | 僕らはみんな河合荘 http://www.tbs.co.jp/anime/kawaisou/
@sorah
sorah / a.rb
Last active August 29, 2015 13:59
def parse(str)
tokens = str.scan(/(.+?)([,=]|\z)/).flatten
pairs = []
stack = []
while token = tokens.shift
case token
when "="
stack << token
@sorah
sorah / a.sh
Last active August 29, 2015 14:00
update_terminal_cwd() {
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
echo -ne "\033]2;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"
}
// http://tour.golang.org/#58
package main
import (
"fmt"
)
type ErrNegativeSqrt float64
func (v ErrNegativeSqrt) Error() string {
// http://tour.golang.org/#62
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
)
type Image struct{}