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
#!/usr/bin/python | |
# encoding: utf-8 | |
import sys | |
import os | |
import struct | |
import sunau | |
import wave | |
from StringIO import StringIO |
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
# encoding: utf-8 | |
import sys | |
import time | |
import shlex | |
from subprocess import Popen, PIPE | |
import atexit | |
import wave | |
from numpy import * |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import sys | |
import os | |
import fcntl | |
import shlex | |
from time import sleep | |
from subprocess import Popen, PIPE |
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
ダンプ | |
>>> timeit.timeit('ujson.dumps(data)', setup='import ujson;'+setup, number=10) | |
0.05042099952697754 | |
>>> timeit.timeit('cPickle.dumps(data)', setup='import cPickle;'+setup, number=10) | |
0.2684299945831299 | |
>>> timeit.timeit('json.dumps(data)', setup='import json;'+setup, number=10) | |
0.10378503799438477 | |
パース | |
>>> timeit.timeit('ujson.loads(text)', setup='import ujson;'+setup+';text=ujson.dumps(data)', number=10) |
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
# MacでAndroidSDK、p7zipのインストールをしておきます。 | |
# ターゲットのSO-03Cは予めICSインストール、root取得、CWM-Installしておきます。 | |
参考: | |
- ICS化&root取得: http://arkdroid.info/024/ | |
- CWM-Install: https://play.google.com/store/apps/details?id=com.pvy.CWMinstaler | |
- 下記手順の基礎: http://blog.mapoyon.info/archives/106 | |
CWMの使い方は、sonyロゴが明るくなるあたりでVolUPキーを連打 | |
backup&restoreでSDカードにバックアップしたりレストアしたり出来る。 |
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 sys | |
from subprocess import Popen, PIPE | |
import json | |
import requests | |
if sys.platform=='linux': | |
iwlist = Popen('iwlist wlan0 scan'.split(), stdout=PIPE) | |
grep = Popen('grep Address:'.split(), | |
stdin=iwlist.stdout, stdout=PIPE) | |
awk = Popen(['awk', '{print $5}'], |
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
from itertools import imap, islice, izip | |
def make_binstream(img): | |
def _bytestream(dt): | |
stream = izip(islice(dt,0,None,3), islice(dt,1,None,3), islice(dt,2,None,3)) | |
while 1: | |
# bits: 8コのboolアレイ | |
bits = [stream.next()==('\x00','\x00','\x00') for i in range(8)] | |
yield chr(reduce(lambda a,b: (a<<1) + b, bits)) # bitsを1バイトに変換 | |
dt = img.ConvertToMono(255,255,255).GetData() |
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 flat(d): | |
res = [] | |
for k,v in d.items(): | |
if isinstance(v, dict): | |
res.extend([('.'.join([k,ck]), cv) for ck, cv in flat(v).items()]) | |
else: | |
res.append((k,v)) | |
return dict(res) | |
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 sys | |
import win32api | |
import win32security | |
import win32event | |
import win32gui | |
sa = win32security.SECURITY_ATTRIBUTES() | |
sa.SECURITY_DESCRIPTOR.SetSecurityDescriptorDacl(True, None, False) | |
# saを指定しておかないと別のユーザで起動したときにMutexが衝突しなくなる | |
mutex = win32event.CreateMutex(sa, False, 'unique-string...') | |
err = win32api.GetLastError() |
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
BUILD_DIR=./build | |
DIST_DIR=./dist | |
define PullProc | |
$(BUILD_DIR)/$1: | |
@echo Pull: $(NAME) | |
mkdir -p $(BUILD_DIR)/$1 | |
cd $(BUILD_DIR); #git clone $(URL) | |
endef |
OlderNewer