Skip to content

Instantly share code, notes, and snippets.

View tamanobi's full-sized avatar

Kohki YAMAGIWA tamanobi

View GitHub Profile
@tamanobi
tamanobi / bot.js
Created June 16, 2015 13:11
NodeJSでTweet(node-twitter必要)
var bot = new twitter({
consumer_key : '',
consumer_secret : '',
access_token_key : '',
access_token_secret : ''
});
bot.post('statuses/update', {status: 'I am a tweet'}, function(error, tweet, response){
if (!error) {
console.log(tweet);
@tamanobi
tamanobi / features.py
Created June 30, 2015 03:39
local invariant feature in OpenCV3.0.0-dev in Python2.7.6
# -*- coding: utf-8 -*-
import cv2
import numpy as np
print u'OpenCV Version:'+cv2.__version__
import sys
print u'Python Version:'+str(sys.version_info)
img = cv2.imread('../query/test21.jpg')
@tamanobi
tamanobi / features_modified.py
Created July 13, 2015 00:25
Measuring processing time of OpenCV's feature detector(ORB/KAZE/AKAZE/FAST/BRISK).
# -*- coding: utf-8 -*-
import cv2
import numpy as np
print u'OpenCV Version:'+cv2.__version__
import sys
print u'Python Version:'+str(sys.version_info)
img = cv2.imread('./test_data/image000001.png')
@tamanobi
tamanobi / superelipse.r
Last active March 26, 2021 15:43
等高線グラフでスーパー楕円を描画する
n <- 100 # num. of mesh
a <- 1.0 # x-axis param
b <- 1.0 # y-axis param
r <- 2.5 # when r is 2.5, it's superelipse
x <- seq( -a, a, length = n )
y <- seq( -b, b, length = n )
z <- matrix(0, n, n)
for (i in 1:n) {
for (j in 1:n) {
# superelipse
@tamanobi
tamanobi / wavelet_simple.py
Created July 18, 2015 02:00
画像に対してウェーブレット変換を行います。
# coding:utf-8
import numpy as np
import cv2
# mean + diff
def WaveletTransformAxisY(img):
tmp = img.astype(np.uint16)
row, col = tmp.shape[:2]
size = row/2
dst = np.zeros(tmp.shape[:2], np.uint16)
@tamanobi
tamanobi / SCurve.py
Created August 26, 2015 05:21
adjust contrast based on human's property
# -*- coding:utf-8 -*-
'''
adjust contrast based on human's property
Inverse S curve
see also: http://ci.nii.ac.jp/els/110007380719.pdf?id=ART0009242456&type=pdf&lang=jp&host=cinii&order_no=&ppv_type=0&lang_sw=&no=1437772911&cp=
'''
import sys
import numpy as np
import cv2
@tamanobi
tamanobi / linkforpukiwiki.js
Created January 16, 2016 11:09
pukiwiki用にリンクを生成するBookmarklet(Javascript)
(function() {
var title = document.getElementsByTagName("title")[0].innerHTML;
title = title.replace(/(^\s*)|(\s*$)/g, '');
var url = document.URL;
var forpukiwiki="[[" + title + ">" + url + "]]";
function ev(e) {
e.preventDefault();
e.clipboardData.setData('text/plain', url);
}
document.addEventListener('copy', (function(){
@tamanobi
tamanobi / mywatch.sh
Last active February 7, 2016 05:26
ファイルの変更を定期的に監視して、特定のコマンドを実行するシェルスクリプト ref: http://qiita.com/tamanobi/items/74b62e25506af394eae5
#!/bin/sh
# see also http://mizti.hatenablog.com/entry/2013/01/27/204343
usage() {
echo "実行するには2個の引数が必要です。
第一引数: 監視対象ファイル名
第二引数: 監視対象ファイルが更新された際に実行されるコマンド
例: ./autoexec.sh a.cpp 'g++ a.cpp && ./a.cpp'"
}
update() {
echo `openssl sha256 -r $1 | awk '{print $1}'`
@tamanobi
tamanobi / take-title.lisp
Last active March 17, 2016 01:23
take title. You can get website title from URL.
(ql:quickload '(:drakma :plump :clss :babel :guess))
(defun charset-to-encoding (charset)
(cond
((string= charset "EUC-JP") :eucjp)
((string= charset "UTF-8") :utf-8)
((string= charset "SJIS") :cp932)))
(defun guess-encoding (input-vector)
(charset-to-encoding (guess:CES-GUESS-FROM-VECTOR input-vector :jp)))
@tamanobi
tamanobi / sicp1-22.scm
Last active September 28, 2016 10:43
SICP1-22の回答(Gauche)
(use srfi-19)
(define (runtime)
(time->seconds (current-time)))
(define (find-divisor n test-divisor)
(cond ((> (square test-divisor) n) n)
((divides? test-divisor n) test-divisor)
(else (find-divisor n (+ test-divisor 1)))))
(define (divides? a b) (= (remainder b a) 0))