Skip to content

Instantly share code, notes, and snippets.

View p-geon's full-sized avatar
🕊️
pigeoning

Pigeon p-geon

🕊️
pigeoning
View GitHub Profile
# initialize
ip link
sudo su
apt update
apt upgrade -y
apt install -y openssh-server vim
# method-1
sudo service network-manager stop
sudo update-rc.d -f network-manager remove
@p-geon
p-geon / Makefile
Last active February 23, 2021 08:00
Docker+LaTeX
export PWD=`pwd`
export DIR=.
export FILENAME=main
# ===========================================
en: ## compile LaTeX with English
@make tex CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make aux CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make tex CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make tex CONTAINER=pman0214/alpine-texlive-ja-epspdf
@make dvi CONTAINER=pman0214/alpine-texlive-ja-epspdf
@p-geon
p-geon / Makefile
Last active February 23, 2021 12:29
GeneralPurpose for CC-56 Blog
## ENVs
# basic
export PWD=`pwd`
# docker
export CONTAINER_NAME=container_name
export DIR_DOCKER=docker
export DOCKERFILE_NAME=Dockerfile
export EXPOSED_PORT=8888
export CONTAINER_ID=`docker ps --format {{.ID}}`
# --------------------------------------------------------
import tensorflow as tf
AUTOTUNE = tf.data.experimental.AUTOTUNE
import pathlib
import random
import os
import IPython.display as display
import matplotlib.pyplot as plt
@p-geon
p-geon / python_utils.py
Last active May 14, 2021 09:08
python useful snippets
# for docker inside, "ls ./ && ls ../"
import os; print(os.listdir('./'), os.listdir('../'))
# =====
# images
# =====
'''read tif'''
!pip install tifffile==2020.9.3
import tifffile
tifffile.imread('filename.tif')
def unet(x, ch, depth, cut_path=False):
conv_kwargs = {'kernel_size': (3, 3), 'strides'=(1, 1), 'dilation_rate'=(1, 1),
'padding'='same', 'use_bias'=True, 'bias_initializer'='zeros', 'kernel_initializer'='he_normal'}
for _ in range(2):
x = tf.keras.layers.Convolution2D(ch, **conv_kwargs)(x)
x = tf.keras.layers.BatchNormalization()(x)
x = tf.keras.layers.Activation('relu')(x)
if(depth != 0):
path = x
from skimage import io
import matplotlib.pyplot as plt
def imshow(img, dpi=150):
if(len(img.shape)==2):#grayscale
plt.figure(dpi)
plt.imshow(img)
plt.gray()
plt.show()
else:
# 色を使用
autoload -Uz colors
colors
# scp needs locate this
echo "[loading] ~/.zshrc"
# 補完
# autoload -Uz compinit
# compinit
echo "[loading] ~/.zprofile"
# =========================================
## hook command: cd -> cd + ls
cdls ()
{
\cd "$@" && ls
}
! pip install -q termcolor==1.1.0
from termcolor import colored
print(colored('hello', 'red'), colored('world', 'green'))
print(colored("hello red world", 'red'))
# ---
red = "\x1b[31m"
red_ = "\x1b[0m"
print(f"{red}red{red_}a")