Skip to content

Instantly share code, notes, and snippets.

@tkhk
tkhk / luajson.md
Last active August 29, 2015 14:26

lua の json モジュールは array と object をどのように区別しているのか

lua-users の Json Modules (http://lua-users.org/wiki/JsonModules) の pure lua で書かれてるものを読んでみた.
基本的にはそれぞれ独自に array 判定関数を作っていて, 中身のロジックは大体同様で以下のようなものだった.

  • テーブル内のすべてのキーをチェックする
  • type が number かつ連番であれば, array とみなす
  • 空のテーブルは空のリストとする

cmj-JSON4Lua

http://json.luaforge.net/

a = "a"
b = "b"
c = "c"
print(a and b or c) -- b
a = nil
b = "b"
c = "c"
print(a and b or c) -- c
@tkhk
tkhk / research_connections.sql
Last active May 31, 2017 04:10
the number of connections to MySQL (group by HOST)
SELECT COUNT(*), SUBSTRING(HOST, 1, POSITION(':' in HOST)-1) AS ip FROM INFORMATION_SCHEMA.PROCESSLIST GROUP BY ip;
@tkhk
tkhk / think_ansible.md
Last active May 28, 2018 07:44
WIP: ansible playbook 雑記

ansible playbook 雑記

playbook を書く上で

  • 「何をしたか」
  • 「何を考えるか」
  • 「何が辛かったか」

を忘れないように書いておく

@tkhk
tkhk / cfn_except-tag-only-changesets.sh
Created February 5, 2019 03:40
CloudFormation ChangeSet
#!/bin/sh
change_set_arn=arn:aws:cloudformation:ap-northeast-1:xxxxxxxxxxxxxxxxxxxxx
aws cloudformation describe-change-set --change-set-name $change_set_arn | jq '.Changes[].ResourceChange | select(.Scope[] | contains("Tags") | not) | .'
@tkhk
tkhk / cfn_except-tag-only-changesets.sh
Created February 5, 2019 03:40
CloudFormation ChangeSet 内の Tags だけの変更を除外する
#!/bin/sh
change_set_arn=arn:aws:cloudformation:ap-northeast-1:xxxxxxxxxxxxxxxxxxxxx
aws cloudformation describe-change-set --change-set-name $change_set_arn | jq '.Changes[].ResourceChange | select(.Scope[] | contains("Tags") | not) | .'
@tkhk
tkhk / td-agent-memo.md
Created February 8, 2019 05:57
td-agent の個人用メモ
aws ec2 describe-instances | jq -r '.Reservations[].Instances[].Tags[] | select(.Key == "Name") | .Value'
#!/bin/bash
if [ $# -ne 1 ]; then
echo "ERROR: Need profile name"
exit 1
fi
profile_name=$1
stack_name=$(aws cloudformation list-stacks --profile ${profile_name} --region ap-northeast-1 \
| jq -r '.StackSummaries[] | .StackName + "\t" + .StackStatus' \