Skip to content

Instantly share code, notes, and snippets.

require 'json'
require 'open-uri'
require 'uri'
require 'websocket-client-simple'
class ChromeDebugger
class CmdError < StandardError
attr_reader :data
def initialize(data)
@data=data
@tarui
tarui / analyze_mallocdetail.rb
Created June 26, 2018 11:23
mallocdetailinfo2graph
require 'rbplotly'
# monkey patch
class IRuby
def self.display(html)
html.render.sub(/style="height: 100%; width: 100%;"/,'style=""')
end
end
This file has been truncated, but you can view the full file.
<html><head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script><meta charset="utf-8" />
<!-- generated by ansi-to-html 0.0.3 https://github.com/uu59/ansi-to-html -->
</head><body style="color:#fff;background-color:#000">
<pre>
Starting master_postgres_1 ...
AK Starting master_postgres_1 ... <span style='color:#0A0;'>done</span> BStarting master_redis_1 ...
Starting master_mysql_1 ...
AK Starting master_redis_1 ... <span style='color:#0A0;'>done</span> BAK Starting master_mysql_1 ... <span style='color:#0A0;'>done</span> Bpostgres:5432 - accepting connections
mysqld is alive
/usr/local/lib/ruby/2.6.0/rubygems/util.rb:17: [BUG] Segmentation fault at 0x00007f59172a5e50
ruby 2.6.0dev (2018-06-22) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0025 p:---- s:0175 e:000174 CFUNC :read
c:0024 p:---- s:0172 e:000171 CFUNC :readpartial
c:0023 p:---- s:0169 e:000168 CFUNC :read
c:0022 p:0047 s:0165 e:000164 METHOD /usr/local/lib/ruby/2.6.0/rubygems/util.rb:17
c:0021 p:0184 s:0159 e:000158 METHOD /usr/local/lib/ruby/2.6.0/rubygems/remote_fetcher.rb:294
c:0020 p:0039 s:0150 e:000149 METHOD /usr/local/lib/ruby/2.6.0/rubygems/remote_fetcher.rb:325
# Copy from https://github.com/docker-library/ruby/blob/752c5f7cf44870ceae77134b346d20093053c370/2.4/Dockerfile
FROM buildpack-deps:jessie
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document --platform ruby'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc
@tarui
tarui / before after # feasibility study of Proc#call optimization
Last active October 24, 2017 14:26
feasibility study of Proc#call optimization
require 'benchmark/ips'
f=proc{}
g=proc{|i| i>0 ? g.call(i-1):0 }
N=2000
Benchmark.ips do |x|
x.report("f"){ f.call }
x.report("g"){ g.call(N) }
end
# ====== before =================================
Warming up --------------------------------------
@tarui
tarui / analyze_vm_exec_core_by_perf.rb
Created October 21, 2017 06:27
analyze_vm_exec_core_by_perf.rb
data=`perf annotate -svm_exec_core --show-total-period --stdio`.split(/\n/)
ins="before"
cnt=Hash.new{0}
total=0
data.each{|line|
case line
when /INSN_ENTRY\((.*)\)/
ins = $1
when /END_INSN/
ins = "none"
From d05d3e3b95d354f5f59232ace4db24ff859a5bcd Mon Sep 17 00:00:00 2001
From: Masaya TARUI <tarui@prx.jp>
Date: Tue, 4 Mar 2014 20:22:13 +0900
Subject: [PATCH] introduce st_foreach_update, st_foreach_update_check
---
hash.c | 47 ++++++++++------
internal.h | 5 ++
st.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 214 insertions(+), 15 deletions(-)
@tarui
tarui / answer2.txt
Last active December 22, 2015 04:08
https://codeiq.jp/ace/yuki_hiroshi/q432 に対する回答(今は問題が読めませんが)
24689222839,0
ENV: Ruby
※締め切り後に調べた内容で解説を再編集しています。
Binary Indexed Treeとか知りませんでした(汗
インデックスの振り方が大変独特ですね。。。
https://twitter.com/debiru/status/374400678182928384
から
プログラミングコンテストでのデータ構造
$ tail -n2 *.log
==> 193p194_1.log <==
21.601350999999987
31.410000 0.490000 31.900000 ( 31.928621)
==> 193p194_2.log <==
20.781295
29.910000 0.330000 30.240000 ( 30.335949)
==> 193p194_3.log <==