Skip to content

Instantly share code, notes, and snippets.

View monmon's full-sized avatar
🌴
On vacation

monmon

🌴
On vacation
View GitHub Profile
@monmon
monmon / .gitconfig
Created December 20, 2013 05:11
あるコミットオブジェクトのファイルをとりあえずviewで見るためのalias
[alias]
tmp = !sh -c 'git co $1 $2 && git reset $2 > /dev/null && fpath=$2 && tmpfile=/tmp/$1."${fpath##*.}" && mv -f $fpath $tmpfile && git co -- $fpath && view $tmpfile && rm -f $tmpfile' -
@monmon
monmon / q4.21.js
Created March 17, 2014 11:24
sicpの問題4.21が一瞬読めなかったのでJavaScriptで書く
(function (n) {
return (function (fact) {
return fact(fact, n);
})(function (ft, k) {
return (k === 1) ? 1
: k * (ft(ft, (k - 1)));
});
})(10)
@monmon
monmon / gist:d5c7a1f784818225abe6
Created May 22, 2014 01:40
git rm でファイルを削除した時、そのファイルがあったディレクトリが空になるならば、そのディレクトリごと削除される
[10:37] ~/tmp/2014-05-22/test
% git --version
git version 1.9.0
[10:37] ~/tmp/2014-05-22/test
% git init
Initialized empty Git repository in /Users/no-kumagai/tmp/2014-05-22/test/.git/
[10:37] ~/tmp/2014-05-22/test
(git)-[master]-% ll
@monmon
monmon / substr_bug.pl
Last active August 29, 2015 14:04
Perl v5.8.5で内部文字列をsubstrするとbugる
#!perl
use strict;
use warnings;
use utf8;
use Devel::Peek;
my $str = '{"a":"b","c":"あ"}';
Dump $str;
print <<EOS;
@monmon
monmon / variadic.swift
Created January 2, 2016 03:18
Swift Variadic Parameters
func variadic(items: Any...) {
print(items.joinWithSeparator(" = ")) // 何も表示されない
print(items.map({ String($0) }).joinWithSeparator(" = ")) // a = b
}
variadic("a", "b")