Skip to content

Instantly share code, notes, and snippets.

Sorah Fukumori sorah

Block or report user

Report or block sorah

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View a.rb
class Foo
def initialize
@hooks = []
@methods = {}
@existing_methods = self.methods
end
def add(mode=nil, &block)
@hooks << block
end
View a.md

Commits around degrade in https://github.com/rails/rails/issues/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 Aug 29, 2015
homebrew: link missing LinkedKegs again
View relink.sh
View a.diff
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 Mar 27, 2014
zabbix -> idobata
View zabbix2idobata.sh
# 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 Aug 29, 2015
アニメ 2014 年春期 (4月-7月)
View anime-2014-spring.md

未ソート

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/
View a.rb
def parse(str)
tokens = str.scan(/(.+?)([,=]|\z)/).flatten
pairs = []
stack = []
while token = tokens.shift
case token
when "="
stack << token
View a.sh
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"
}
View 62.go
// http://tour.golang.org/#62
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
)
type Image struct{}
View 58.go
// http://tour.golang.org/#58
package main
import (
"fmt"
)
type ErrNegativeSqrt float64
func (v ErrNegativeSqrt) Error() string {
You can’t perform that action at this time.