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 | |
""" | |
matplotlibで日本語フォントを使うサンプル | |
""" | |
import matplotlib.pyplot | |
import matplotlib.font_manager | |
# for Mac |
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
--- networkx-1.5/networkx/drawing/nx_pylab.py 2011-06-04 09:45:38.000000000 +0900 | |
+++ nx_pylab.py 2011-10-01 01:48:06.000000000 +0900 | |
@@ -21,7 +21,8 @@ | |
# All rights reserved. | |
# BSD license. | |
-__all__ = ['draw', | |
+__all__ = ['set_fontproperties', | |
+ 'draw', | |
'draw_networkx', |
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 | |
""" | |
networkx-1.5にて日本語フォントを使う | |
patch...https://gist.github.com/1247256 | |
$ patch -p1 < nx_pylab.py.patch | |
""" | |
import matplotlib.font_manager | |
import networkx |
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 | |
""" | |
unofficial Google Weather API | |
http://www.google.com/ig/api?weather=,,,35693692,139700260&hl=ja | |
レスポンスのエンコーディングは hl=jaの場合Shift-JIS hl=enの場合ASCII | |
<xml_api_reply version="1"> | |
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0"> | |
<forecast_information> |
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 logging | |
import logging.handlers | |
import traceback | |
"""よく使うRotateLoggerの設定とtracebackの設定""" | |
def getRotateLogger(path, name='', level=logging.DEBUG, **kws): | |
maxBytes = kws.get('maxBytes', 1024*1024*50) |
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 com.novus.casbah.mongodb | |
val con = mongodb.MongoConnection() // localhost に接続 | |
val db = con("test") | |
val col = db("scala") | |
val item = mongodb.MongoDBObject("name"->"testtest", "age"->23) | |
col += item | |
println(col.find().toList) |
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 datetime | |
import time | |
import unicodedata | |
import MeCab | |
from HTMLParser import HTMLParser | |
import re | |
class MyMeCab(object): | |
''' |
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 os | |
import time | |
from multiprocessing import Process | |
import pymongo | |
def print_tweet(collection): | |
db = pymongo.Connection().twitter | |
pid = os.getpid() |
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
JAVA_BASE=/System/Library/Frameworks/JavaVM.framework/Versions/1.6 | |
JAVA_HOME=$(JAVA_BASE)/Home | |
TARGET=MeCab | |
JAVAC=$(JAVA_HOME)/bin/javac -encoding utf-8 | |
JAVA=$(JAVA_HOME)/bin/java -Dfile.encoding=utf-8 | |
JAR=$(JAVA_HOME)/bin/jar | |
CXX=g++ | |
INCLUDE=/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers | |
PACKAGE=org/chasen/mecab |
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 java.io.{InputStreamReader, FileInputStream, BufferedReader} | |
import java.nio.charset.{Charset, CharsetDecoder, CodingErrorAction} | |
/* | |
通常 Source.fromFile("sample.txt")では | |
java.nio.charset.MalformedInputException: Input length = 1 | |
エラーが出る場合使う. | |
*/ | |
object IgnoreDecodeTest{ |
OlderNewer