Skip to content

Instantly share code, notes, and snippets.

@shunsukeaihara
shunsukeaihara / cc.py
Created January 23, 2013 08:45
some of color correction algorithm in python
# -*- coding: utf-8 -*-
import numpy as np
import Image
import sys
def from_pil(pimg):
pimg = pimg.convert(mode='RGB')
nimg = np.asarray(pimg)
nimg.flags.writeable = True
return nimg
@shunsukeaihara
shunsukeaihara / changefinder.py
Last active August 14, 2023 06:28
Change finder algorithm
# -*- coding: utf-8 -*-
import numpy as np
import math
def LevinsonDurbin(r, lpcOrder):
"""
from http://aidiary.hatenablog.com/entry/20120415/1334458954
"""
a = np.zeros(lpcOrder + 1,dtype=np.float64)
@shunsukeaihara
shunsukeaihara / karaoke_spectral_subtruction.py
Last active August 3, 2021 23:07
Singing voice enhancement by spectral subtraction method using karaoke sound
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import scipy as sp
import numpy as np
import math
import optparse
import tempfile
import wave
from itertools import izip
@shunsukeaihara
shunsukeaihara / pic.py
Created January 23, 2013 08:37
power iteration clustering
#!/opt/local/bin/python
# module power iteration clustering
import numpy as NP
from scipy.cluster.vq import kmeans2
def calcNorm1(v):
return NP.sum(NP.fabs(v))
def calcDelta(v,v2):
@shunsukeaihara
shunsukeaihara / to_elasticsearch.js
Last active June 15, 2020 03:48
lambda script for kinesis firehose with cloudwatch logs
'use strict';
const zlib = require('zlib');
const AWS = require('aws-sdk');
function transformLogEvent(payload, logEvent) {
var source = buildSource(logEvent.message, logEvent.extractedFields);
source['@id'] = logEvent.id;
source['@timestamp'] = new Date(1 * logEvent.timestamp).toISOString();
source['@message'] = logEvent.message;
@shunsukeaihara
shunsukeaihara / .eslintignore
Last active June 1, 2019 10:37
vscode +eslint + prettier + react-native + typescriptの設定群. vscodeにはeslintとprettierだけを入れる. このあたり標準決めて欲しい
node_modules/
@shunsukeaihara
shunsukeaihara / main.go
Last active December 20, 2018 09:09
long poll chat server in go and redis
// chatserver project main.go
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/golang/glog"
"github.com/zenazn/goji"
"github.com/zenazn/goji/web"
@shunsukeaihara
shunsukeaihara / upsampling.ipynb
Last active September 15, 2018 11:46
upsampling with biquad low-pass filter
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shunsukeaihara
shunsukeaihara / mcl.rb
Created January 23, 2013 08:38
markov cluster algorithm in ruby
#!/usr/bin/ruby
class MCL
def initialize(path,min=0.00001,minpred=0.1)
@minimum=min
@minimunPred=minpred
@matrix=Hash.new
id=0
edgelist=Array.new
@shunsukeaihara
shunsukeaihara / crawl.py
Last active April 22, 2016 10:42
rongorongoのThomas Barthel's Transliteration Systemのデータをクローリングしてファイルに保存したり、文字の正規化や分解を行うスクリプト。詳細は以下 http://argmax.jp/index.php?ron
# -*- coding: utf-8 -*-
from BeautifulSoup import BeautifulSoup
import urllib2
import re
URL = "http://kohaumotu.org/rongorongo_org/translit/%s.html"
for i in range(97,123):
url = URL % chr(i)
html = urllib2.urlopen(url).read()