Skip to content

Instantly share code, notes, and snippets.

@tatsuru
tatsuru / awsevent2gcal
Last active May 25, 2018 — forked from i2tsuki/awsevent2gcal
AWS のイベントを calendar に登録するくん
View awsevent2gcal
#!/bin/sh
set -eux
PROFILE="default"
RESP="$(aws --profile ${PROFILE} --region "us-east-1" health describe-events --query 'events[?eventTypeCategory==`scheduledChange` && statusCode == `upcoming`]')"
LENGTH="$(echo ${RESP} | jq 'length')"
for i in $(seq 0 $(($LENGTH-1)))
View output.txt
...
write(2, "test\n", 5test
) = 5
exit_group(0) = ?
+++ exited with 0 +++
View nothing.go
tatsuru@moryo$ strace ./nothing /tmp
execve("./nothing", ["./nothing"], [/* 53 vars */]) = 0
arch_prctl(ARCH_SET_FS, 0x4b4868) = 0
sched_getaffinity(0, 8192, [f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]) = 64
mmap(0xc000000000, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
munmap(0xc000000000, 65536) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1a20c3f000
mmap(0xc820000000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc820000000
mmap(0xc81fff8000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc81fff8000
mmap(0xc000000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc000000000
View gist:7fbaa10fa425f5808764
tatsuru@moryo$ for char in {a..z}; do; which -a $char; done ~
a not found
b not found
c not found
d not found
e not found
f not found
g not found
h not found
i not found
View GCE.txt
- GCE 個人アカウント作る。$300 無料すごい
- なんか既にプロジェクトがあった。前に作ったGAEっぽい
- gcutil deprecated って言われてた https://cloud.google.com/compute/docs/gcutil/
-- のでこっちでやる https://cloud.google.com/compute/docs/gcloud-compute/#install
-- gcutil を PATH から消せとか zshrc への追加とかいろいろやってくれて便利
- startup-script 便利
-- gcloud compute instances create test01 --metadata startup-script="apt update; apt install -y nginx-full" --image debian-8
- metadata https://cloud.google.com/compute/docs/metadata
-- 変なヘッダつけないと 403
--- curl -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/disks/0/mode
View .psqlrc
\timing on
\set HISTSIZE 1000000
\pset pager off
@tatsuru
tatsuru / x240battery.sh
Last active Aug 29, 2015
X240 Battery Plugin for Mackerel.io
View x240battery.sh
#!/bin/bash
#
# [plugin.metrics.battery]
# command = "/path/to/x240battery.sh"
#
LANG=C
if [ x$MACKEREL_AGENT_PLUGIN_META = x1 ]; then
cat <<EOF
@tatsuru
tatsuru / mackerel-plugin-theschwartz.sh
Created Dec 19, 2014
Theschwartz job count plugin for Mackerel
View mackerel-plugin-theschwartz.sh
#!/bin/bash
usage() {
echo "Usage: $0 [-m METRIC_NAME] [-u USER] [-p PASSWORD] [-d DATABASE] [-h]"
}
METRIC_NAME=theschwartz.count
DBUSER=root
DBPASS=
DATABASE=theschwartz
@tatsuru
tatsuru / parse.rb
Last active Feb 1, 2016
ec2 RI parser
View parse.rb
#!/usr/bin/env ruby
require 'json'
def parse(uri)
JSON.parse `curl -s #{uri}`.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
end
puts %w(
region
You can’t perform that action at this time.