Skip to content

Instantly share code, notes, and snippets.

View chezou's full-sized avatar

Aki Ariga chezou

View GitHub Profile
str = <<`EOS`
printenv
EOS
#=> "RBENV_VERSION=2.0.0-p353\n...
[121] pry(main)> case str
[121] pry(main)* when ->(t){ t.size == 4 }
[121] pry(main)* puts 'size eq 4'
[121] pry(main)* else
[121] pry(main)* puts 'not eq 4'
[121] pry(main)* end
size eq 4
=> nil
@chezou
chezou / example2.rb
Created January 30, 2014 15:03
classとメソッドの設計は適当ですが、こんなイメージです。
count = 0
if target_user_ids.empty?
count += Foo.all.count
else
target_user_ids.each do |user_ids|
count += Foo.where(user_id: user_ids).count
end
end
@chezou
chezou / kytea.0.4.6.diff
Last active August 29, 2015 14:03
patch for kytea 0.4.6
diff --git a/src/lib/kytea.cpp b/src/lib/kytea.cpp
index 8dbae30..04324c3 100644
--- a/src/lib/kytea.cpp
+++ b/src/lib/kytea.cpp
@@ -74,6 +74,11 @@ void Kytea::addTag(typename Dictionary<Entry>::WordMap& allWords, const KyteaStr
Entry::setInDict(it->second->inDict,dict);
}
}
+
+
@chezou
chezou / dict.jl
Last active August 29, 2015 14:10
Julia Dict() execution time
dict = Dict()
@time for i in [1:10000000]
dict[i] = 1
end
# elapsed time: 22.824151615 seconds (2413509808 bytes allocated, 9.20% gc time)
dict = Dict()
@time for i in [1:10000]
dict[i] = 1
end
@chezou
chezou / WordCount.jl
Created December 4, 2014 15:05
Word count benchmark using MeCab
# Julia using -O wakati
using Benchmark
using MeCab
function count_word(text::UTF8String)
mecab = Mecab("-O wakati")
counts = Dict{UTF8String, Int}()
for word in split(sparse_tostr(mecab, text))
counts[word] = get(counts, word, 0) + 1
end
julia> Pkg.update()
INFO: Updating METADATA...
...snip...
INFO: Building Homebrew
remote: Counting objects: 818, done.
remote: Compressing objects: 100% (232/232), done.
remote: Total 818 (delta 644), reused 759 (delta 585)
Receiving objects: 100% (818/818), 92.06 KiB | 0 bytes/s, done.
Resolving deltas: 100% (644/644), completed with 144 local objects.
From https://github.com/Homebrew/homebrew
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chezou
chezou / mikon-plot-ttest.ipynb
Last active August 29, 2015 14:13
mikon example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.