>>> t = Tree()
>>> d = {}
>>> d["hoge"] = 1
>>> d["fuga"] = 2
>>> d["piyo"] = 3
>>> d
{'fuga': 2, 'piyo': 3, 'hoge': 1}
>>> t["a"]["b"]["hoge"]=1
>>> t["a"]["b"]["fuga"]=2
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 multiprocessing | |
import os | |
import time | |
def is_alive(pid): | |
try: | |
os.kill(pid, 0) | |
except OSError: | |
return False | |
else: |
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 requests | |
from pymongo import Connection | |
con = Connection("localhost", 27017) | |
db = con["tumblr"] | |
url = "http://api.tumblr.com/v2/blog/tumblr.non117.com/posts/" | |
params = {"api_key" : ""} | |
def fetch(offset): |
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
# history | |
HISTFILE=~/.histfile | |
HISTSIZE=10000 | |
SAVEHIST=10000 | |
setopt hist_ignore_dups | |
setopt share_history | |
zstyle :compinstall filename '$HOME/.zshrc' | |
#alias |
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 json | |
import mimetypes | |
import os | |
import urllib | |
import Image | |
import requests | |
api_key = "" |
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 cPickle as pickle | |
import pylab | |
#from mpl_toolkits.mplot3d.axes3d import Axes3D | |
from numpy import arange, sqrt, cos, sin, matrix, identity, pi, ones, convolve | |
from scipy import signal | |
from scipy.interpolate import UnivariateSpline | |
def squarediff(x, y): |
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 urllib, urllib2 | |
from oauth import OAuth | |
class Api(): | |
def __init__(self, atoken="", atokensecret="", ckey="", csecret="", hostname=""): | |
self.oauth = OAuth(ckey, csecret, atoken, atokensecret) | |
self.site = "http://api.tumblr.com/v2/blog/%s/" % (hostname) | |
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 cPickle as pickle | |
import pylab | |
from mpl_toolkits.mplot3d.axes3d import Axes3D | |
from numpy import arange, sqrt, cos, sin, matrix, identity, pi | |
from scipy import signal | |
from scipy.interpolate import UnivariateSpline | |
def squarediff(x, y): |
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 scipy import signal | |
def lpf(x, cutoff_freq, samp_rate): | |
norm_pass = cutoff_freq/(samp_rate/2) | |
norm_stop = 1.5*norm_pass | |
N, Wn = signal.buttord(wp=norm_pass, ws=norm_stop, gpass=2, gstop=30, analog=0) | |
b, a = signal.butter(N, Wn, btype='low', analog=0, output='ba') | |
y = signal.lfilter(b, a, x) | |
return y |
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
#include<Python/Python.h> | |
#include<vector> | |
#include<map> | |
#include<queue> | |
#include<functional> | |
using namespace std; | |
struct Point{ | |
short x,y; |