This file contains hidden or 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 'test/unit/assertions' | |
module AssertChange | |
# fixme message? | |
def assert_change(value_proc, options = {}, &event_proc) | |
change = Change.new(value_proc) | |
change.perform(event_proc) | |
case |
This file contains hidden or 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 'test/unit' | |
require 'active_support/all' | |
module BeforeAfterAll | |
extend ActiveSupport::Concern | |
included do | |
class << self | |
def beforeall(&block) | |
@_beforeall = block |
This file contains hidden or 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 'test/unit' | |
require 'active_support/all' | |
module OnlyOnce | |
extend ActiveSupport::Concern | |
included do | |
def self.singleton_method_added(method_name) | |
if method_name == :startup || method_name == :shutdown |
This file contains hidden or 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 'test/unit' | |
require 'active_support/all' | |
module OnlyOnce | |
extend ActiveSupport::Concern | |
included do | |
class << self | |
def inherited_with_onlyonce(sub) | |
inherited_without_onlyonce(sub) |
This file contains hidden or 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
# Rails で test-unit を使う. 参考: | |
# * https://github.com/test-unit/test-unit-activesupport | |
# * https://github.com/rails/rails/blob/master/activesupport/lib/active_support/test_case.rb | |
# | |
require 'minitest' | |
def Minitest.autorun; end # remove Minitest at_exit process | |
require 'active_support/test_case' | |
require 'active_support/testing/tagged_logging' | |
require 'active_support/testing/assertions' |
This file contains hidden or 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 'gimei' | |
def daime(max=99) | |
[*(2..max)].sample.to_s.tr('0123456789','〇一二三四五六七八九') + "代目" | |
end | |
def name | |
"#{daime}#{Gimei.first.kanji}" | |
end |
This file contains hidden or 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 | |
HOST=$1 | |
if [ -z "$HOST" ]; then | |
echo "$0 host [port]" | |
exit 1 | |
fi | |
PORT=${2:-443} | |
openssl s_client -tls1 -connect $HOST:$PORT 2>&1 < /dev/null | openssl x509 -enddate | awk -F '=' '/^notAfter/{ print $2 }' |
This file contains hidden or 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
File.open("x.txt",'w'){|f| f.puts File.read("SKK-JISYO.L", external_encoding: Encoding::EUC_JP).encode(Encoding::UTF_8).split(/\n+/).map{|x| x.scan(%r!/(\p{Han}{2})(?=[;/])!).flatten.first if x !~ /[a-z]/ }.compact.flatten.sort.uniq } |
This file contains hidden or 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
--- conn-ssl.c.orig 2014-10-16 09:37:47.303936573 +0000 | |
+++ conn-ssl.c 2014-10-16 09:38:31.513421919 +0000 | |
@@ -296,7 +296,7 @@ | |
return false; | |
} | |
- newctx = SSL_CTX_new(SSLv23_method()); | |
+ newctx = SSL_CTX_new(TLSv1_method()); | |
if (!newctx) { | |
LogOpenSSLError("Failed to create SSL context", NULL); |
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'benchmark' | |
require 'ostruct' | |
require 'hashie' | |
n = 1000000 | |
O = Struct.new(:foo, :bar, :baz) | |
puts "Benchmark: Initialize" |