This file contains 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
def map_f(w, model): | |
return model.get_vector(w) | |
def get_vector_matrix_for_w2v_model(model, vocab=None): | |
"""Create vector matrix for word2vec model""" | |
if vocab is None: | |
vocab = model.vocab | |
# vect_mat = np.array([model.get_vector(w) for w in vocab]) | |
p = Pool(multiprocessing.cpu_count() - 1) |
This file contains 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
import mojimoji | |
def is_non_sense_word(word): | |
"""return True if non sense word like a@~ """ | |
hankaku_word = mojimoji.zen_to_han(word.decode("utf-8"), kana=False) | |
#半角記号を含む語は削除 | |
pattern = re.compile("[!-/:-@[-`{-~]") | |
if pattern.search(hankaku_word) is not None: | |
return True | |
This file contains 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
import multiprocessing | |
import itertools | |
def get_trajectory(arg1, arg1): | |
return [999,888,777,666] | |
def get_traj_as_star(arg): | |
return get_trajectory(arg[1], arg[2]) | |
def run_multi_particle(num_particle, num_time, num_mesh, multi_thread=True): |
This file contains 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/bash | |
echo "index,datetime,count" > newfile.csv | |
cat original_file.csv >> newfile.csv |
This file contains 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
# encoding: utf-8 | |
def remove_symbol str | |
wide_symbol = "、 。 , . ・ : ; ? ! ゛ ゜ ´ ` ¨ ^  ̄ _ ヽ ヾ ゝ ゞ 〃 仝 々 〆 〇 ー ― ‐ / \ ~ ∥ | … ‥ ‘ ’ “ ” ( ) 〔 〕 [ ] { } 〈 〉 《 》 「 」 『 』 【 】 + - ± × ÷ = ≠ < > ≦ ≧ ∞ ∴ ♂ ♀ ° ′ ″ ℃ ¥ $ ¢ £ % # & * @ § ☆ ★ ○ ● ◎ ◇ ◆ □ ■ △ ▲ ▽ ▼ ※ 〒 → ← ↑ ↓ 〓" | |
str.gsub!(/[!-\/:-@\[-`{-~]*/,"") # => remove word consisting of only numeric or special chars like 123, `"$# | |
str.gsub!(/[#{wide_symbol}]/,"") | |
# str.gsub!(/[!。、*・]/,"") | |
str.gsub!(/\p{Symbol}/,"") | |
str | |
end |
This file contains 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
RSpec::Matchers.define :call_system_command do |expected| | |
match do |actual| | |
actual.should_receive(:'`').with(/#{expected}/) #|| actual.should_receive(:system).with(expected) | |
end | |
end |
This file contains 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
#encoding: utf-8 | |
require 'rake' | |
task :show_table_gen, :arg1 do |t, arg| | |
# TODO eval(arg[]) is NOT secure code. | |
model_name = eval(arg['arg1']) # => NOT secure code... | |
str = <<-EOS | |
<table> | |
EOS |
This file contains 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
# act like vim | |
setw -g mode-keys vi | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
bind-key -r C-h select-window -t :- | |
bind-key -r C-l select-window -t :+ |
This file contains 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
1. libeventの導入 | |
安定版のソース(自分は2.0.16) | |
http://libevent.org/ | |
手順はここを参照 | |
https://github.com/libevent/libevent | |
普通に | |
./configure -> make -> sudo make install | |
でできます。 |
This file contains 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
The Hacker Way | |
ハッカーのいきかた | |
原文 | |
The Hacker Way (in Facebook' S-1 Filling.) | |
http://www.sec.gov/Archives/edgar/data/1326801/000119312512034517/d287954ds1.htm#toc | |
強い企業にする一環として、世界に大きなインパクトを与えようとし、また他のすばらしい人々から学ぼうとするような偉大な人々にとって最高の場所になるように努めてきました。私たちはHacker Wayと呼ぶユニークなカルチャーやマネジメント手法を構築してきました。 |