Skip to content

Instantly share code, notes, and snippets.

@nibral
nibral / levenshtein_distance.js
Last active March 2, 2016 15:21
Calculate Levenshtein distance (a.k.a. edit distance) between two strings
'use strict';
/*
Calculate Levenshtein distance(edit dstance) between str1 and str2.
*/
const calculateLevenshteinDistance = (str1, str2) => {
// Initialize distance table
let distanceTable = new Array(str1.length + 1);
for (let row = 0; row < str1.length + 1; row++) {
distanceTable[row] = new Array(str2.length + 1);
// 標準入力から1行ずつ読み込み
var readLineFromStdin = function(callback) {
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 入力(の一部)が到着
var fragment = '';
process.stdin.on('data', function(chunk) {
if (chunk === '') {
return;
@nibral
nibral / launch_cmder.cmd
Last active January 3, 2016 10:47
Launch Cmder in specified directory
@echo off
rem 指定した作業ディレクトリでCmderを立ち上げるバッチ
rem 使い方: Cmder.bat <作業ディレクトリ>
rem 本来Cmderは/STARTオプションで起動するディレクトリが指定できるはずだが、
rem 指定を無視してCmderを呼び出したプログラムの作業ディレクトリで起動してしまう。
rem とりあえずの対策として、このバッチでコマンドプロンプトを噛ませることにした。
rem HKEY_CLASSES_ROOT\Directory\shell\Cmder Here\commandに「launch_cmder.bat "%V"」で
rem 登録すると、フォルダの右クリックメニューに出てくれて便利。
@nibral
nibral / wpa_supplicant.conf
Created December 10, 2015 15:09
wlan config sample
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID"
#psk="password"
psk=2f6a0beddf2f0588ee426b0c3a0e3d9a523bb07a05cb857f85d826da80fa75c4
}
@nibral
nibral / flac_to_alac.ps1
Created November 25, 2015 12:10
Encode FLAC to ALAC with ffmpeg on Powershell
Get-ChildItem -Filter "*.flac" | % { ffmpeg.exe -i "$_" -acodec alac "$($_.BaseName).m4a" }