-
月50時間まで無料、カード登録不要
-
$ rails server -b 0.0.0.0
- 無制限で無料、要カード登録
## Analyze Wikipedia access data | |
# Data format | |
# https://wikitech.wikimedia.org/wiki/Analytics/Data/Pageviews | |
# Files | |
# https://dumps.wikimedia.org/other/pageviews/ | |
filename = "pageviews-20170101-000000" | |
file = File.open(filename) | |
access_data = [] | |
file.each_line do |text| |
# Analyze Wikipedia access data | |
# https://dumps.wikimedia.org/other/pageviews/ | |
# Data format | |
# https://dumps.wikimedia.org/other/pagecounts-raw/ | |
# "ja "はじまりのものだけ(=Wikipediaだけ)をカウントしている。 | |
# ja.X の説明は上記のData format参照。 | |
# 取得したサンプルデータ | |
# "en Tokyo_Station 3 0\n" | |
# "ja 名古屋駅 3 0\n" | |
# "ja 大阪駅 4 0\n" |
# encoding: utf-8 | |
# Analyze Wikipedia access data older version | |
# https://dumps.wikimedia.org/other/pagecounts-raw/ | |
require "cgi" | |
filename = "20120301-000000-ja.txt" | |
file = File.open(filename, "r:UTF-8") | |
list = [] | |
while text = file.gets | |
begin | |
next unless text =~ /^ja/ |
## Analyze Wikipedia access data | |
# Data format | |
# https://wikitech.wikimedia.org/wiki/Analytics/Data/Pageviews | |
# Files | |
# https://dumps.wikimedia.org/other/pageviews/ | |
# "ja "はじまりのものだけ(=Wikipediaだけ)をカウントしている。 | |
# ja.X の説明は上記のData format参照。 | |
## 結果(pageviews-20170101-000000の駅名上位10件) | |
# 八丁堀駅 12 | |
# 品川駅 9 |
# peco + git branch -r + git co | |
function peco-g-branch-checkout () { | |
local selected=$(git branch -r | peco --query "$LBUFFER" | awk -F/ '{print $NF}') | |
if [ -n "$selected" ]; then | |
git checkout -b ${selected} origin/${selected} | |
fi | |
} |
# http://docs.ruby-lang.org/ja/2.3.0/class/Benchmark.html | |
require "benchmark" | |
Benchmark.bm do |x| | |
x.report("100000.times:") { 100000.times{a = "1"} } | |
end |
# https://speakerdeck.com/a_matsuda/3x-rails | |
# メソッド呼び出し回数の記録 | |
class MethodCounter | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
calls = [] | |
trace = TracePoint.new(:call, :c_call) do |tp| | |
calls << [tp.defined_class, tp.method_id, tp.lineno] |
# This is not a very beautiful code, but it's just an example... | |
# And it kinda works... | |
require 'benchmark/ips' | |
Rails.application.config.after_initialize do | |
Rails.application.extend Module.new { | |
def call(e) | |
super | |
p before: GC.stat | |
# RUBY_GC_HEAP_INIT_ SLOTS=1000000 + GC.disable | |
Benchmark.ips do |x| |
require "ripper" | |
require "pp" | |
code = <<STR | |
10.times do |n| | |
puts n | |
end | |
puts code | |
STR |