Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / suicide.py
Created December 18, 2013 02:23
親が死んだら自殺する子.py
import multiprocessing
import os
import time
def is_alive(pid):
try:
os.kill(pid, 0)
except OSError:
return False
else:
@non117
non117 / inotify_daemon.py
Created December 18, 2013 03:12
python inotify daemon
import multiprocessing
import os
import time
from functools import partial
import pyinotify
def is_alive(pid):
try:
os.kill(pid, 0)
@non117
non117 / distance.py
Created February 10, 2014 16:12
緯度経度 to メートル
from math import sqrt, sin, cos, pi
def distance(lat1, lon1, lat2, lon2):
"""
Hubeny method
args : latitude1, longitude1, latitude2, longitude2 (degree)
return : m
"""
@non117
non117 / zoi.py
Created July 2, 2014 13:27
zoizoi
import cv2
import numpy as np
def main():
f = 'hoge.png'
im = cv2.imread(f)
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
hist = cv2.calcHist([im_gray],[0],None,[256],[0,256])
cv2.normalize(hist, hist, 0, 255, cv2.NORM_MINMAX)
im_out = cv2.equalizeHist(im_gray, hist)
@non117
non117 / payo.py
Created September 13, 2014 10:27
pathlibとshutilを使ってファイルのコピーとか
# -*- coding: utf-8 -*-
import shutil
from pathlib import Path
dst = Path('dst')
lis = open('prior-reedit-sorted.txt').readlines()
for filename in lis:
d,_,_, f = filename.strip().split('_')
path = Path(d) / Path('_'+f)
@non117
non117 / kancolle.py
Created September 26, 2014 11:55
やばいやつ
# -*- coding: utf-8 -*-
import json
import operator
import re
import time
import threading
from datetime import datetime
from functools import partial
from getpass import getpass
from random import randint