Skip to content

Instantly share code, notes, and snippets.

View FGtatsuro's full-sized avatar

FGtatsuro FGtatsuro

View GitHub Profile
socat -v tcp-listen:8080 system:pbcopy
socat stdin tcp:localhost:8080
https://github.com/alpine-docker/socat/blob/master/Dockerfile
https://github.com/FGtatsuro/copycat
https://momijiame.tumblr.com/post/48934531325/socat-%E3%82%92%E4%BD%BF%E3%81%86%E3%81%A8%E5%90%84%E7%A8%AE%E3%82%BD%E3%82%B1%E3%83%83%E3%83%88%E3%81%AE%E6%93%8D%E4%BD%9C%E3%81%8C%E6%8D%97%E3%82%8A%E3%81%BE%E3%81%8F%E3%82%8B%E4%BB%B6
xsel
ssh x11
@FGtatsuro
FGtatsuro / inject_decorator.py
Created July 17, 2019 02:19
Dynamic injected value
import functools
import random
import typing
def decorator(
field_name: str = 'injected_field'
):
def inner(func: typing.Callable):
@FGtatsuro
FGtatsuro / gcloud_snippet.sh
Last active July 31, 2019 15:15
Google Cloud SDK utility
# リソースタイプ
$ gcloud deployment-manager types list | awk 'NR>=2' | grep -E -v 'beta|alpha' | sort -u
$ gcloud deployment-manager types list | tail -n +2 | grep -E -v 'beta|alpha' | sort -u
$ gcloud deployment-manager types list --filter='name !~ alpha|beta'| tail -n +2 | sort -u
$ gcloud deployment-manager types list --filter='name:compute AND NAME !~ alpha|beta' | tail -n +2 | sort -u
# マシンタイプ
# NOTE: --sort-byオプションがCPUS,MEMORY_GBに対して上手く効かない
$ gcloud compute machine-types list --filter='zone:asia-northeast1-a' | sort -n -k 3,3 # CPU数順
$ gcloud compute machine-types list --filter='zone:asia-northeast1-a' | sort -n -k 4,4 # メモリ順
ANSIBLE_LOAD_CALLBACK_PLUGINS=1 ANSIBLE_STDOUT_CALLBACK=json \
ansible devenv -i inventory/hosts -m setup | jq '.plays[0].tasks[0].hosts.devenv.ansible_facts.ansible_env.HOME'
BRANCH=`git branch --format "%(refname:short)" | grep -v master | peco`; git push origin $BRANCH:$BRANCH && hub pull-request
git status --short | awk '{if ($1 ~ /M/) print $2}' | peco | xargs git add
git status --short | awk '{if ($1 ~ /(M|??)/) print $2}' | peco | xargs git add
git status --short | awk '{if ($1 ~ /(M|D|\?\?)/) print $2}' | peco | xargs git add
BRANCH=`git branch | awk -v ORS='' '{print $2}'`; \
git checkout master; \
hub pr list -f '%U' | peco | hub merge - && \
git push origin master && git branch -D $BRANCH && git push origin :$BRANCH
@FGtatsuro
FGtatsuro / spring.py
Created January 12, 2019 02:15
回帰分析
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
f = open('springData.txt')
f.readline()
df = pd.read_csv(f, header=None, names=('dist', 'mass'), delimiter=' ')[:-6]
df['force'] = df['mass'] * 9.81
@FGtatsuro
FGtatsuro / docker_internal_ip.sh
Created September 28, 2018 01:56
Dockerコンテナの内部IPの取得
docker inspect github_traverse_container | jq '.[0].NetworkSettings.IPAddress'
@FGtatsuro
FGtatsuro / mynotebook.py
Created September 26, 2018 15:41
First cell of my notebook
import numpy as np
import pandas as pd
# Ref: https://pandas.pydata.org/pandas-docs/stable/options.html#available-options
pd.options.display.max_rows = 1000
@FGtatsuro
FGtatsuro / Dockerfile
Created August 7, 2018 10:01
Dockerfile template for Python
# FYI:
# - https://docs.docker.com/engine/reference/builder/
# - https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
# - https://hub.docker.com/_/python/
FROM python:3.7
# Backward compatibility with deprecate onbuild image.
# FYI: https://github.com/docker-library/python/pull/314/files#diff-7531449f9a1a85f134eba7d960a91c91L1
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
@FGtatsuro
FGtatsuro / Makefile
Last active December 19, 2018 18:21
sample Makefile
TAG = my_performance:0.1
CONTAINER_NAME = my_performance_oneshot
TIME_ZONE = Asia/Tokyo
SRC = $(wildcard tests/*.py) $(wildcard tests/configs/*.py) $(wildcard tests/scenarios/*.py)
.PHONY: all build test result clean lint format tags unittest
all: test
build: .build