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
find dir_name -name "*.org"|xargs rm |
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 url2text(url) | |
html = open(url).read | |
doc = Nokogiri::HTML(html.toutf8, nil, 'utf-8') | |
doc.text | |
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
node: Beginning with 0.8.0, this recipe now comes with npm. | |
It appears you already have npm installed at /usr/local/lib/node_modules/npm. | |
To use the npm that comes with this recipe, first uninstall npm with | |
`npm uninstall npm -g`, then run this command again. | |
If you would like to keep your installation of npm instead of | |
using the one provided with homebrew, install the formula with | |
the `--without-npm` option. | |
Error: An unsatisfied requirement failed this build. |
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
a = [{"word":"a","tfidf":0.5}, | |
{"word":"b","tfidf":0.1}, | |
{"word":"c","tfidf":0.2}] | |
b = [{"word":"d","tfidf":0.3}, | |
{"word":"a","tfidf":0.2}, | |
{"word":"c","tfidf":0.4}] | |
c = [{"word":"a","tfidf":0.7}, | |
{"word":"b","tfidf":0.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
def decorator_with_args(decorator_to_enhance): | |
""" | |
デコレータに引数を与えて返す関数 | |
""" | |
def decorator_maker(*args, **kwargs) : | |
def decorator_wrapper(func) : | |
return decorator_to_enhance(func, *args, **kwargs) | |
return decorator_wrapper | |
return decorator_maker |
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
//console.assertの第一引数がfalseの場合、第二引数が表示されます | |
//trueの場合は何も表示されません。 | |
console.assert(true,"trueだと何も表示しない") | |
console.assert(false,"falseだとこの内容を出力する") |
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
#こんなエラーが出たときの対処法 | |
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position xx: ordinal not in range(128) |
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
# -*- coding: utf-8 -*- | |
from pyquery import PyQuery as pq | |
url = "http://www.sicafe.net/macPackageManageTips/html/homebrewPythonInstall.html" | |
query = pq(url) | |
for a in query.find("a"):#CSSセレクタ!! | |
print pq(a).text() | |
#出力結果 | |
#前略 |
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
# -*- coding: utf-8 -*- | |
import networkx as nx#先ほど入れたnetworkxをインポート | |
g = nx.DiGraph()#有向グラフを表現するためのオブジェクトを作成 | |
g.add_edge("user1","user3")#user1からuser3に投票 | |
g.add_edge("user2","user3")#user2からuser3に投票 | |
g.add_edge("user2","user1")#user2からuser1に投票 | |
g.add_edge("user3","user1")#user3からuser1に投票 | |
g.add_edge("user4","user2")#user4からuser2に投票 | |
g.add_edge("user1","user4")#user1からuser4に投票 |
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
hg init |