Skip to content

Instantly share code, notes, and snippets.

@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" }
@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 / 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 登録すると、フォルダの右クリックメニューに出てくれて便利。
// 標準入力から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 / 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);
{
"env": {
"node": true,
"es6": true
},
"rules": {
"array-bracket-spacing": [
2,
"never"
],
@nibral
nibral / post_slack_from_lambda.js
Last active January 5, 2018 06:50
環境変数SLACK_WEBHOOK_URLを設定して使うこと
const https = require('https');
const url = require('url');
exports.handler = function(event, context) {
// prepare https POST request
const reqOptions = url.parse(process.env.SLACK_WEBHOOK_URL);
reqOptions.method = 'POST';
reqOptions.headers = {
'Content-Type': 'application/json'
};
# Make directory tree as below
#--------------------
#.
#├─ Makefile
#└─ src
# └─ main.c
#--------------------
# Project settings
PROG = hello
@nibral
nibral / nginx.conf
Last active December 1, 2018 10:44
reverse proxy
server {
listen 80;
server_name example.com;
charset UTF-8;
auth_basic "Login message";
auth_basic_user_file /path/to/.htpasswd;
location / {
proxy_redirect off;
// 参考:
// http://www.misuzilla.org/Blog/2016/01/31/CreateYourOwnHttpServerUsingCSharp
// http://qiita.com/akiray03/items/3607c60ec8b221b3c2ba (Node.jsはブロックしないよ!)
'use strict';
const net = require('net');
const HTTP_RESPONSE = [
"HTTP/1.0 200 OK",