Skip to content

Instantly share code, notes, and snippets.

@non117
non117 / tumblr.py
Created June 3, 2013 13:12
tumblrの全postをmongoDBに突っ込むアレ ※ クロール中にpostすると, バグります.
# -*- 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):
@non117
non117 / zsh.rc
Created May 30, 2013 11:29
zsh.rc
# history
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups
setopt share_history
zstyle :compinstall filename '$HOME/.zshrc'
#alias
@non117
non117 / recognize.py
Last active December 17, 2015 14:29
docomoの文字認識APIらっぱー. 画像urlか画像ファイルへのパスを与えると, OCRして文字列を返します.
# -*- coding: utf-8 -*-
import json
import mimetypes
import os
import urllib
import Image
import requests
api_key = ""
@non117
non117 / researchlib.py
Created May 20, 2013 05:53
卒論で使った研究用ライブラリ
# -*- 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):
@non117
non117 / api.py
Created May 12, 2013 14:45
tumblrのOAuthトークンを取得するだけのスクリプト
# -*- 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)
@non117
non117 / test.md
Last active December 14, 2015 06:49
SortedDictの機能をもった木構造のdict
>>> 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
@non117
non117 / lib.py
Created January 30, 2013 15:42
研究用ライブラリ
# -*- 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):
@non117
non117 / lpf.py
Created January 29, 2013 09:37
バターワースフィルタを設計して, LPFかけた信号を返してくれるえらいやつ
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
@non117
non117 / dtw.cpp
Last active December 11, 2015 21:28
DPマッチングを計算するPythonのC++拡張.
#include<Python/Python.h>
#include<vector>
#include<map>
#include<queue>
#include<functional>
using namespace std;
struct Point{
short x,y;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0