Skip to content

Instantly share code, notes, and snippets.

@yuki-takeichi
yuki-takeichi / lisp.json
Last active October 15, 2015 17:18
Recursive JSON object traversal by PostgreSQL
{"car":"H","cdr":{"car":"e","cdr":{"car":"l","cdr":{"car":"l","cdr":{"car":"o","cdr":{"car":" ","cdr":{"car":"w","cdr":{"car":"o","cdr":{"car":"r","cdr":{"car":"l","cdr":{"car":"d","cdr":{"car":"!","cdr":{}}}}}}}}}}}}}
@yuki-takeichi
yuki-takeichi / sum3.js
Last active October 29, 2015 07:53
Promise sample
//sum([1,2,3]) == 6
function sum3() {
var a = sum([1]);
var b = sum([1,2]);
var c = sum([1,2,3]);
return a + b + c;
}
function sum(nums) {
@yuki-takeichi
yuki-takeichi / pango.rb
Last active October 29, 2015 13:48
homebrew pango 1.36.1 with patch
# This fomula is based on: https://raw.githubusercontent.com/Homebrew/homebrew/108279f2050e8768dd8ffd372285d09b6b00d9b7/Library/Formula/pango.rb # pango 1.36.1
require 'formula'
class Pango < Formula
homepage 'http://www.pango.org/'
url 'http://ftp.gnome.org/pub/GNOME/sources/pango/1.36/pango-1.36.1.tar.xz'
sha256 '42e4b51cdc99e6878a9ea2a5ef2b31b79c1033f8518726df738a3c54c90e59f8'
option 'without-x', 'Build without X11 support'
#!/bin/sh
## see https://pqrs.org/osx/karabiner/document.html.ja#export
cli=/Applications/Karabiner.app/Contents/Library/bin/karabiner
$cli set remap.jis_command2eisuukana_prefer_command 1
/bin/echo -n .
/bin/echo
@yuki-takeichi
yuki-takeichi / nginx.conf
Created December 20, 2015 08:55
Nginx reverse proxy for debugging
worker_processes 1;
events {
worker_connections 1024;
}
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
@yuki-takeichi
yuki-takeichi / new_macbook.md
Last active January 8, 2016 03:38
MacBook入手したらやること

前提

  • OS X Yosemite (10.10.5)
  • MacBook Pro (Retina, 15-inch, Mid 2015)

とりあえずhomebrew / homebrew-caskを導入

これやらないとなにも始まらない。

Xcode / Xcode Command Line Tools 入れる

@yuki-takeichi
yuki-takeichi / Makefile
Created February 23, 2016 12:11
openssl test
hoge: hoge.c
gcc -o $@ -g $^ `pkg-config --cflags --libs /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc`
.PHONY: clean run
clean:
rm -rf hoge hoge.o
run: hoge
./hoge
@yuki-takeichi
yuki-takeichi / mongofdtest.js
Last active February 24, 2016 02:48
mongo fd test
var MongoClient = require('mongodb').MongoClient;
var mongoUri = "mongodb://192.168.11.2:27017/hoge";
function mapM(fs, cb) {
var xs = [];
function _mapM(fs, cb) {
var f = fs.shift();
f(function(x) {
xs.push(x);
if (fs.length == 0) {
@yuki-takeichi
yuki-takeichi / wsay
Created July 11, 2016 05:02
Weblio say command
#!/bin/bash
WORD=$1
TMP_FILE=/tmp/wsay.wav
[ -z "$WORD" ] && echo "arg missing" && exit 1
WAV_URL=$(curl -s http://ejje.weblio.jp/content/$WORD | grep playSwfSound | sed -e "s/^.*playSwfSound('\([^']*\)', *'\([^']*\)'.*).*\$/\1\2\.wav/")
curl -s -o $TMP_FILE $WAV_URL
afplay $TMP_FILE
@yuki-takeichi
yuki-takeichi / papertrail-logfilter
Created August 12, 2016 03:58
papertrail-logfilter
#! /bin/bash
# extracts a log file for a specified host from Papertrail tsv file
HOSTNAME=$1
FILENAME=$2
TSVFILE=$3
awk -F '\t' "{if (\$5 == \"$HOSTNAME\" && \$9 == \"$FILENAME\") print \$10}" $TSVFILE