Skip to content

Instantly share code, notes, and snippets.

View taiju's full-sized avatar

HIGASHI Taiju taiju

View GitHub Profile
@taiju
taiju / PostsController.php
Created September 27, 2019 03:02
CakePHP で任意のステータスコードで JSON レスポンスを返すサンプル
<?php
namespace App\Controller;
class PostsController extends AppController
{
public function initialize()
{
seq 3 | xargs -I{a} bash -c 'seq 3 | xargs -I{b} bash -c '\''seq 3 | xargs -I{c} bash -c '\'\\\'\''seq 3 | xargs -I{d} echo {a} {b} {c} {d}'\'\\\'
@taiju
taiju / 9x9.sh
Last active August 13, 2018 22:33
九九表
$ seq 9 | xargs -I{a} bash -c 'seq 9 | xargs -I{b} expr {a} \* {b}' | xargs printf "%2d\0" | xargs -0 -n9
1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81
@taiju
taiju / build-tmpl.md
Last active July 26, 2018 08:25
TSVを元にテンプレートをビルドする時に使えそうなイディオム

コマンド

$ seq 2 4 | xargs -n1 -i bash -c 'read $(head -n1 data.tsv) < <(sed -n {}p data.tsv) && export $(head -n1 data.tsv) && envsubst < tmpl.json > row-{}'

データ等

$ ls -1
data.tsv
tmpl.json
$ cat tmpl.json
(*
カリキュラマシーン 〜 第3回 ESM オフラインどう書くの問題を OCaml で解いてみたやつ
記事: http://emattsan.hatenablog.com/entry/20170528/1495976693
問題: https://gist.github.com/mattsan/2ec7888056c6d02c3cc398d1279e5708
*)
open Core
type exp_t =
| Num of Big_int.big_int
(*
瞬き星 〜 第2回 ESM オフラインどう書くの問題を OCaml で解いてみたやつ
記事: http://emattsan.hatenablog.com/entry/20151230/1451449205
問題: https://gist.github.com/mattsan/07674b095908fda117a0
*)
open Core
type color_t = W | R
(*
行列のできるラーメン屋 ESM オフラインどう書くの問題を OCaml で解いてみたやつ
記事: http://mtsmfm.github.io/2015/10/22/esm-doukaku.html
問題: https://gist.github.com/mtsmfm/4b8ffb53ffac055f5843
*)
open Core
type state_t = Empty | Waiting | Eating | Resting
@taiju
taiju / start
Last active March 8, 2018 11:44
WSL 上でフォルダを開いたり、ファイルを開いたりするコマンドのラッパ
#!/bin/sh
if [ -f "$@" ]; then
cmd.exe /c start "$@"
else
cd "$@" && cmd.exe /c start . && cd "$OLDPWD"
fi
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="import" href="bower_components/mt-entries-list/mt-entries-list.html">
<custom-style>
<style>
mt-entries-list {
--mt-entries-list-item: {
list-style-type: square;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="import" href="./path/to/google-map/google-map.html"><!-- https://www.webcomponents.org/element/GoogleWebComponents/google-map -->
<style>
google-map {
height: 600px;
}
</style>