This file contains hidden or 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
| class MethodMissing(object): | |
| def __getattr__(self, name): | |
| try: | |
| return self.__getattribute__(name) | |
| except AttributeError: | |
| def method(*args, **kw): | |
| return self.method_missing(name, *args, **kw) | |
| return method | |
| def method_missing(self, name, *args, **kw): |
This file contains hidden or 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
| from MeCab import Tagger | |
| ''' | |
| Example: | |
| >>> import MeCab | |
| >>> import mecab_wakachi_patch.py | |
| >>> m = Mecab.Tagger() | |
| >>> m.wakachi('僕と契約して魔法少女になってよ') | |
| ''' |
This file contains hidden or 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
| #!/usr/bin/python | |
| #coding: utf8 | |
| import re | |
| import pymongo | |
| import MeCab | |
| sub_url = re.compile('(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)').sub | |
| sub_user_hash = re.compile('(@|#)[a-zA-Z0-9_]+').sub |
This file contains hidden or 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
| #!/usr/bin/python | |
| # coding: utf8 | |
| import sys | |
| import re | |
| sub = re.compile('\n').sub | |
| def hoge(text): | |
| fuga = sub('', text).split(',') | |
| foo = {} |
This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "io/ioutil" | |
| ) | |
| func getCounts() { |
This file contains hidden or 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
| #!/usr/bin/python | |
| #coding: utf8 | |
| import sys | |
| import os | |
| import platform | |
| from pit import Pit | |
| PROJECT = """\ | |
| <?xml version="1.0" encoding="UTF-8"?> |
This file contains hidden or 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: utf8 | |
| """pymongoのAutoReferenceにパッチ当てるやつ | |
| リスト内のDBRef全部にクエリを発行せずに{$in: [1,2,...,n]}する。 | |
| Example: | |
| >>> from pymongo.son_manipulator import AutoReference, NamespaceInjector | |
| >>> import autoreference_dbref_patch | |
| """ |
This file contains hidden or 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.BufferedReader; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.io.UnsupportedEncodingException; | |
| import java.util.Iterator; | |
| public class BufferedFileReader { | |
| private static BufferedFileReader opener = new BufferedFileReader(); |
This file contains hidden or 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
| //tiny requestFileSystem Wrapper | |
| //author @ukyo | |
| //apache license | |
| //refer: http://d.hatena.ne.jp/shirokurostone/20111014/1318593601 | |
| var fs = (function(window){ | |
| var fs = {}, | |
| BlobBuilder = window.WebKitBlobBuilder || window.MozBlobuilder || window.MSBlobBuilder, | |
| requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem, |
This file contains hidden or 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
| function download(blob, filename) { | |
| const objectURL = window.URL.createObjectURL(blob), | |
| a = document.createElement('a'), | |
| e = document.createEvent('MouseEvent'); | |
| //a要素のdownload属性にファイル名を設定 | |
| a.download = filename; | |
| a.href = objectURL; | |
| //clickイベントを着火 |
OlderNewer