Skip to content

Instantly share code, notes, and snippets.

Avatar

non117 non117

  • Kyoto
View GitHub Profile
@non117
non117 / tumblr.py
Created Jun 3, 2013
tumblrの全postをmongoDBに突っ込むアレ ※ クロール中にpostすると, バグります.
View tumblr.py
# -*- 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):
View 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 Dec 17, 2015
docomoの文字認識APIらっぱー. 画像urlか画像ファイルへのパスを与えると, OCRして文字列を返します.
View recognize.py
# -*- 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
卒論で使った研究用ライブラリ
View researchlib.py
# -*- 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
tumblrのOAuthトークンを取得するだけのスクリプト
View api.py
# -*- 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 Dec 14, 2015
SortedDictの機能をもった木構造のdict
View test.md
>>> 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 Jan 30, 2013
研究用ライブラリ
View lib.py
# -*- 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 Jan 29, 2013
バターワースフィルタを設計して, LPFかけた信号を返してくれるえらいやつ
View lpf.py
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 Dec 11, 2015
DPマッチングを計算するPythonのC++拡張.
View dtw.cpp
#include<Python/Python.h>
#include<vector>
#include<map>
#include<queue>
#include<functional>
using namespace std;
struct Point{
short x,y;
View angelworm.py
#!/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