Skip to content

Instantly share code, notes, and snippets.

@mogi
mogi / gen_contact.sh
Last active November 2, 2018 05:37
運用連絡の雛形を出力する
SS=$1
# get json
curl -s "https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fstatus.cybozu.com%2Frss%2Fmonitor-${SS}?tz=540" > /tmp/${SS}.json
# output template
cat << EOS
以下の時間帯、サービスにアクセスし辛くなっていました。
現在は解消しています。
EOS
@mogi
mogi / 1.example_inventory.json
Last active April 13, 2018 05:29
inventoryに複数の apt パッケージとバージョンを指定し、1つのroleを実行する
# forest/etc/ansible/canary/java-lives/canary_groups.json
{
"all" : {
"children" : {
"live-fronts" : "",
"live-backs" : ""
},
"vars" : {
"jdk_package" : "cybozu-oracle-jdk-8",
"jdk_version" : "1.8.0.162-1",
#!/bin/sh
# This command is make sure current version and target version are equal.
PACKAGE_NAME=$1
PREF_FILE="/etc/apt/preferences.d/${PACKAGE_NAME}.pref"
if [ ! -e "${PREF_FILE}" ]; then
echo "${PACKAGE_NAME}.pref is not found. Before using, please deploy config file of 'apt pinning'."
exit 1
fi
@mogi
mogi / inventory2json.py
Created March 26, 2018 08:18 — forked from sivel/inventory2json.py
Ansible inventory to dynamic inventory JSON output, accepts all inventory input formats
import sys
import json
from ansible.parsing.dataloader import DataLoader
try:
from ansible.inventory.manager import InventoryManager
A24 = True
except ImportError:
from ansible.vars import VariableManager
@mogi
mogi / subprocess.py
Created December 21, 2015 03:17
test subprocess
(lambda arg: subprocess.check_call(
' '.join([
#"ssh foo.jp", # TODO:delete
"hdfs dfs -test -e /path/to/dir/{0}"
]).format(arg),
shell=True
))(foo)
for i=1, 100 do
if i%3 == 0 and i%5 == 0 then
print(fizzbuzz')
elseif %3 == 0 then
print('fizz')
elseif i%5 == 0 then
print('buzz')
else
print(i)
end
@mogi
mogi / gist:5118118
Last active December 14, 2015 16:49
| static/
| | | css/
| | | fonts/
| | | images/
| | | js/
| | | movies/
| browser_scripts/ # js
| data/
| scripts/ # wsgi
| submodule/
# coding: utf-8
"""
ハンバーガーショップの合計金額計算
"""
import sys
from collections import defaultdict
########
# マスターデータ定義クラス群
@mogi
mogi / gist:4510622
Last active December 10, 2015 23:38
trim duplicate object
def trim_duplicate_by_objects_list(objects_list, obj_attr_name):
trimd = {}
for o in objects_list:
key = getattr(o, obj_attr_name)
if not key:
continue
trimd[key] = o
return trimd.values()
vim $(find . -iname $1)
echo $(find . -iname $1)