Skip to content

Instantly share code, notes, and snippets.

View taiju's full-sized avatar

HIGASHI Taiju taiju

View GitHub Profile
@taiju
taiju / example.sh
Last active October 30, 2017 02:58
入力を3行繰り返して出力するサンプル
echo "foo" | sed 'p;p'
echo "foo" | awk '1;1;1'
echo "foo" | perl -ne 'print;print;print'
echo "foo" | perl -ne 'print "$_"x3'
# 参考: https://unix.stackexchange.com/questions/81904/repeat-each-line-multiple-times
const fst = p => p(x => y => x)
const snd = p => p(x => y => y)
const mult = m => n => s => z => n(m(s))(z)
const one = s => z => s(z)
const two = s => z => s(s(z))
const one_two = x => x(one)(two)
const mult_one_two = x => x(mult)(one_two)
// (fst(mult_one_two))(fst(snd(mult_one_two)))(snd(snd(mult_one_two)))
((p => p(x => y => x))(x => x(m => n => s => z => n(m(s))(z))(x(s => z => s(z))(s => z => s(s(z))))))((p => p(x => y => x))((p => p(x => y => y))(x => x(m => n => s => z => n(m(s))(z))(x => x(s => z => s(z))(s => z => s(s(z)))))))((p => p(x => y => y))((p => p(x => y => y))(x => x(m => n => s => z => n(m(s))(z))(x => x(s => z => s(z))(s => z => s(s(z)))))))
const a = 1
const b = 2
const c = 3
const d = 4
const p1 = x => x(y => y(a)(b))(z => z(c)(d))
const fst = p => p(x => y => x)
const snd = p => p(x => y => y)
fst(snd(p1))
// (p => p(x => y => x))(snd(p1))
@taiju
taiju / six.js
Last active October 9, 2017 12:10
const two = (s) => (z) => (s) ((s) (z))
const three = (s) => (z) => (s) ((s) ((s) (z)))
const mult = (m) => (n) => (s) => (z) => (n) ((m) (s)) (z)
const toInt = (n) => (n) (x => x + 1) (0)
// six = (mult) (two) (three)
// six = ((m) => (n) => (s) => (z) => (n) ((m) (s)) (z)) ((s) => (z) => (s) ((s) (z))) ((s) => (z) => (s) ((s) ((s) (z))))
// six = ((m) => (n) => (s) => (z) => (n) ((m) (s)) (z)) ((x) => (y) => (x) ((x) (y))) ((a) => (b) => (a) ((a) ((a) (b))))
@taiju
taiju / install-galliumos.sh
Created October 2, 2017 21:36
GalliumOS を chrx コマンドで USB にインストールする時のコマンド
# 実行前に USB をアンマウントする
cd ; curl -Os https://chrx.org/go && sh go -t /dev/sdb -L ja_JP.UTF-8 -Z Asia/Tokyo -U taiju -H chromebook
@taiju
taiju / OSO.gs
Last active June 7, 2017 04:17
お掃除おじさん.gs
/*
OSO.gs - お掃除おじさん.gs
毎週のお掃除のタイミングを idobata に通知するおじさんです。
トリガーに設定した曜日の当月の最初の営業日は、追加メッセージ(appendix)を付与します。
* 使い方:
1. 本スクリプトで GAS (Google Apps Script) を作成し、保存します。
2. 下記のスクリプトプロパティを設定します。
idobata_hook_url {idobata の hook URL を指定します (必須)}
@taiju
taiju / Dockerfile
Last active May 1, 2017 01:49
GoDoW (Git on Docker on Windows)
FROM buildpack-deps:scm
RUN apt-get update && apt-get install -y --no-install-recommends \
less \
vim \
&& rm -rf /var/lib/apt/lists/*
RUN git config --global user.name "HIGASHI Taiju" \
&& git config --global user.email "higashi@taiju.info"
COPY id_rsa /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa
ENV LESSCHARSET UTF-8
@taiju
taiju / .mew.el
Created February 8, 2017 05:04
Mew 試用中の設定内容
;; General settings
(setq mew-name "HIGASHI Taiju")
(setq mew-user "higashi")
(setq mew-mail-domain "taiju.info")
;; Password settings
(setq mew-use-cached-passwd t)
(setq mew-use-master-passwd t)
;; SSL settings
seq 2017 2020 | xargs -n1 -IX bash -c 'seq 1 12 | xargs -n1 -IY bash -c '"'"'seq 1 31 | xargs -n1 -IZ printf "%04d%02d%02d\n" X Y Z'"'"'' | xargs -n1 date -R 2>/dev/null -d | awk '$1 == "Fri," && $2 == "13"' | xargs -I{} date -d {} +'%Y/%m/%d'
# 参考: https://github.com/hisaharu/shellgei/blob/master/slides/techconf1/lib/md/index.md
# 上記の日曜日列挙相当をブレース展開を使わずにやってみる実験。xargs + bash -c をネストすると実現できる。モナドっぽい。エスケープがしんどい。
@taiju
taiju / fibo.sql.sh
Created February 6, 2017 08:42
fibonacci by sqlite3
echo 'with recursive fibo(i, j) as (select 0, 1 union all select j, i + j from fibo) select i from fibo limit 50;' | sqlite3