Skip to content

Instantly share code, notes, and snippets.

View tagomoris's full-sized avatar

Satoshi Tagomori tagomoris

View GitHub Profile
require 'webrick'
require 'webrick/https'
require 'openssl'
WEBrick::HTTPServer.new(
:BindAddress => "localhost",
# :Logger => logger,
:Port => 0,
:AccessLog => [],
:DocumentRoot => '.',
@tagomoris
tagomoris / isucon5_regulation.md
Last active November 30, 2015 09:19
ISUCON5決勝レギュレーション

ISUCON5 決勝レギュレーション

更新日時: 2015-10-31 10:30:00

(変更があった場合は変更内容をここに記す)

スケジュール

  • 11:00 競技開始
  • 18:00 作業終了
@tagomoris
tagomoris / encoding_test.rb
Created October 21, 2015 06:54
JRuby 9.0 has/uses wrong cache for Hash keys?
# encoding: ascii-8bit
require 'java'
str = 'hello'
obj = {'hello' => 'world'}
p({str: str, enc: str.encoding, key: obj.keys.first, keyEnc: obj.keys.first.encoding})
# {:str=>"hello", :enc=>#<Encoding:ASCII-8BIT>, :key=>"hello", :keyEnc=>#<Encoding:ASCII-8BIT>}
str = 'hello'.force_encoding('UTF-8')
MBA:~ tagomoris$ ruby -rbenchmark -e '
> C="a"
> N=20_000_000
> Benchmark.bm do |bm|
> bm.report{ N.times{ x = "a".freeze } }
> bm.report{ N.times{ x = C } }
> end
> '
user system total real
1.060000 0.010000 1.070000 ( 1.063368)
hoge
=begin
moge
=end
MBA:gcp tagomoris$ cat hoge.rb
ary1 = ['hoge', 'pos']
ary2 = ['hoge' 'pos']
p ary1
p ary2
MBA:gcp tagomoris$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
MBA:gcp tagomoris$ ruby hoge.rb
["hoge", "pos"]
["hogepos"]
@tagomoris
tagomoris / test_msgpack_ext.rb
Created July 3, 2015 10:18
Testing msgpack-ruby ext type
require 'msgpack'
p MessagePack::VERSION
class UnixTime
def initialize(time)
@t = time.to_i
end
def to_i
@tagomoris
tagomoris / class_stat.result.txt
Created July 3, 2015 10:08
`bundle exec rake test` on fluentd
Enumerable 29 1537
FileUtils 11 770
Kernel 3 369
RR::Adapters::RRMethods 7 357
Test::Unit::Assertions 3 234
Rake::FileUtilsExt 4 152
RR::DoubleDefinitions::Strategies::StrategyMethods 10 130
#<Module:0x007ff96c0c0f90> 1 117
Comparable 19 114
FlexMock::Ordering 10 90
CPU SAMPLES BEGIN (total = 5565) Fri Jun 26 03:17:14 2015
rank self accum count trace method
1 13.35% 13.35% 743 356232 java.lang.Object.<init>
2 11.16% 24.51% 621 356237 java.lang.Object.<init>
3 7.87% 32.38% 438 347669 java.net.SocketInputStream.socketRead0
4 6.86% 39.25% 382 356239 java.lang.Object.<init>
5 6.76% 46.00% 376 356326 java.lang.Object.<init>
6 6.38% 52.38% 355 356331 java.lang.Object.<init>
7 5.53% 57.92% 308 356240 java.lang.Object.<init>
8 4.56% 62.48% 254 356210 org.apache.hadoop.hive.ql.exec.GroupByOperator.updateAggregations
def submit_flush
@next_time = 0
@thread.wakeup
Thread.pass
end
def run
# If the given clock_id is not supported, Errno::EINVAL is raised.
begin