Skip to content

Instantly share code, notes, and snippets.

@yamakk
yamakk / 0_reuse_code.js
Created Feb 15, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yamakk
yamakk / mygoogledocs.py
Created Dec 18, 2011
googledocsをcsvにエクスポート
View mygoogledocs.py
#coding:utf-8
import gdata.docs.data
import gdata.docs.client
import gdata.docs.service
import gdata.spreadsheet.service
"""
SpreadSheet
GoogleDocsからドキュメントをローカルにエクスポートするクラス
アカウント情報とdocumentid, そしてexportしたいファイルの名前が必要
View mymecab.scala
import java.text.Normalizer
import scala.collection.mutable.ArrayBuffer
import org.chasen.mecab.{MeCab, Tagger, Node}
/*
scalac mymecab.scala
scala MyMeCabTest
ArrayBuffer(サイト, リンクフリー, リンクフリー)
@yamakk
yamakk / ignoredecodetest.scala
Created Dec 6, 2011
ignoredecodetest.scala utf-8でdecodeできないファイルをscalaで扱う
View ignoredecodetest.scala
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{
@yamakk
yamakk / mecab-java-0.98.Makefile
Created Dec 5, 2011
mecab-java-0.98 Makefile for MacOS10.6.8
View mecab-java-0.98.Makefile
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
@yamakk
yamakk / multiprocess_mongo.py
Created Dec 4, 2011
multiprocessing to mongodb single processと4processの比較
View multiprocess_mongo.py
#coding:utf-8
import os
import time
from multiprocessing import Process
import pymongo
def print_tweet(collection):
db = pymongo.Connection().twitter
pid = os.getpid()
@yamakk
yamakk / mymecab.py
Created Oct 15, 2011
mymecab.py MyMeCab().parse()
View mymecab.py
#coding:utf-8
import datetime
import time
import unicodedata
import MeCab
from HTMLParser import HTMLParser
import re
class MyMeCab(object):
'''
@yamakk
yamakk / mongodb_scala.scala
Created Oct 15, 2011
MongoDBにScalaで接続
View mongodb_scala.scala
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)
@yamakk
yamakk / rotatelog.py
Created Oct 4, 2011
よく使うRotateLoggerの設定とtracebackの組み合わせ
View rotatelog.py
#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)
@yamakk
yamakk / google_weather_api.py
Created Sep 30, 2011
Google Weather APIから天候、湿度、風速、風向を取得する
View google_weather_api.py
#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>
You can’t perform that action at this time.