Skip to content

Instantly share code, notes, and snippets.

View tomoyk's full-sized avatar
🐳
Containerize

Tomoyuki KOYAMA tomoyk

🐳
Containerize
View GitHub Profile

環境

$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
@tomoyk
tomoyk / reverse_polish_notation.py
Created January 28, 2020 06:03
逆ポーランド記法の構文解析やってみた
in_txt = '13 5 4 + 3 / 4 * -'.split(' ')
symbols = ('+', '-', '*', '/')
stack = []
print("input::", ' '.join(in_txt))
for i,_ in enumerate(in_txt):
# FOUND NUM
if in_txt[i] not in symbols:
stack.append(int(in_txt[i]))
continue
@tomoyk
tomoyk / get-ldap-keys.sh
Created November 11, 2019 08:53
SSH LDAP Wrapper supported multiple keys
#!/bin/bash
user="${1}"
host="ldap://example.com"
base="dc=example,dc=com"
filter1="(& (objectClass=posixAccount) (uid=${user}))"
filter2="sshPublicKey"
id "$user" >/dev/null 2>&1
RESULT=$(ldapsearch -x -LLL -H "$host" -b "$base" "$filter1" "$filter2" \
@tomoyk
tomoyk / dhcpd-lease-table.py
Last active October 26, 2019 04:31
print dhcpd.lease (isc dhcpd) to table-format
#!/usr/bin/env python3.6
def parse_file(file_name: str):
import re
with open(file_name, "r") as file:
file_content = file.read()
file_content = re.sub(r"#.*\n(\n)?|server-duid.+;\n", r'', file_content)
lease_logs = [fc for fc in re.split(r"\n}\n*", file_content)]

My Setup Note on Fedora 30

Install from Repos

sudo dnf install chromium \
terminator \
vim \
vlc \
filezilla \
@tomoyk
tomoyk / esxi-vm-ip-list.sh
Created September 28, 2019 03:36
Get VM IP List by ESXi (Requirements: open-vm-tools)
VM_LIST=`vim-cmd vmsvc/getallvms | awk '{print $1"/"$2}'`
# filter: using `grep`
for vm in $VM_LIST
do
vm_id=`echo $vm | cut -f1 -d'/'`
ip_addr=`vim-cmd vmsvc/get.summary $vm_id | grep ipAddress | grep -o "10.1.1.[0-9]\+"`
vm_name=`echo $vm | cut -f2 -d'/'`
echo $vm_name $ip_addr
done
@tomoyk
tomoyk / provisoning.bash
Last active September 28, 2019 03:38
ansible書くほどでもない時に使える流し込みスクリプト
#!/bin/bash
host_list=`cat <<EOF
bootcamp-vm-25
bootcamp-vm-49
bootcamp-vm-5
bootcamp-vm-8
bootcamp-vm-62
bootcamp-vm-10
bootcamp-vm-15
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:

DBを作成するときにやること

いいかげんおぼえろ

create user 'ユーザー名'@'localhost' identified by 'パスワード';
grant all on データベース名.* to 'ユーザー名'@'localhost';

flush privileges; は不要