Skip to content

Instantly share code, notes, and snippets.

View bluele's full-sized avatar
coding

Jun Kimura bluele

coding
View GitHub Profile
@bluele
bluele / generate_sentence.py
Created May 10, 2012 10:06
Generate japanese sentence.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
__doc__ = u"""
指定したコーパスから文章を生成します
ファイルを読み込んでsplit /[、。]/で分割
"""
__usage__ = u"""
USAGE:
@bluele
bluele / re_pattern.py
Created October 20, 2012 16:21
正規表現のパターン
#-*- coding:utf-8 -*-
__author__ = 'junk'
import unittest
import re
re_hiragana = re.compile(ur"^[ぁ-ゞ]$")
re_kana = re.compile(ur"^[ァ-ヾ]$")
re_kanji = re.compile(ur'^[一-龠]$')
re_number = re.compile(ur'^[-+]?(([1-9]\d+|\d)(?:\.\d+)?)$')
@bluele
bluele / inherit_unicode.py
Created January 26, 2013 19:46
sub-classing unicode
#-*- coding:utf-8 -*-
__author__ = 'bluele'
class SubUnicode(unicode):
def __new__(cls, val, meta={}):
self = unicode.__new__(cls, val)
self.__meta = meta
return self
@bluele
bluele / path.py
Created January 26, 2013 20:10
Path module provide the utility accessors for File path.
#-*- coding:utf-8 -*-
__author__ = 'bluele'
from os.path import exists as op_exists, join as op_join, dirname as op_dirname, basename as op_basename,\
normpath as op_normpath, split as op_split, normcase as op_normcase, splitext as op_splittext
class Path(object):
def __init__(self, path, is_relative=False):
@bluele
bluele / suffixarray.py
Created February 25, 2013 04:53
Suffix Array
#-*- coding:utf-8 -*-
__author__ = 'bluele'
import unittest
class SuffixArray(object):
def __init__(self, string):
self.string = string
@bluele
bluele / hserve
Last active November 8, 2016 14:52
Startup script for simple http server.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
__author__ = 'bluele'
__version__ = '0.10'
__license__ = 'MIT'
__doc__ = """
# simple running
$ hserve
@bluele
bluele / tvschedule.py
Created April 2, 2013 22:47
Get tv schedule.
#-*- coding:utf-8 -*-
__author__ = 'bluele'
from BeautifulSoup import BeautifulSoup as bs
import requests
import re
url = 'http://program.tv.jp.msn.com/tv.php?site=032&mode=06&category=g&area=013&template=program&sdate=20130321&lhour=7&shour=05'
host = 'http://program.tv.jp.msn.com/tv.php'
@bluele
bluele / kickstat.py
Last active December 15, 2015 18:48
get stats of kickstarter' project
#-*- coding:utf-8 -*-
__author__ = 'bluele'
from BeautifulSoup import BeautifulSoup as bs
import urllib
import requests
import re
class Project(object):
@bluele
bluele / google_image_search.py
Last active September 15, 2022 22:20
Python script for Google search by image
#-*- coding:utf-8 -*-
from BeautifulSoup import BeautifulSoup as b
from urllib import quote_plus as q, unquote_plus as unq, urlencode
from urllib2 import build_opener, urlopen, HTTPCookieProcessor
from cookielib import CookieJar
import urlparse
import re
__author__ = 'bluele'
@bluele
bluele / targz.go
Created September 28, 2015 05:18
Golang compress tar.gz example.
package main
import (
"archive/tar"
"compress/gzip"
"io/ioutil"
"log"
"os"
"path"
)