Skip to content

Instantly share code, notes, and snippets.

View steermomo's full-sized avatar
🏠
Working from home

HangL steermomo

🏠
Working from home
View GitHub Profile
src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/targets/ramips/mt7620/packages
src/gz openwrt_kmods https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/targets/ramips/mt7620/kmods/4.14.162-1-18384755d38fc43c447d83d4a3e07054
src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/packages/mipsel_24kc/base
src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/packages/mipsel_24kc/luci
src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/packages/mipsel_24kc/packages
src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/packages/mipsel_24kc/routing
src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.0/packages/mipsel_24kc/telephony
@steermomo
steermomo / init.lua
Created March 29, 2020 08:13
Hammerspoon config
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "Y", function()
local win = hs.window.focusedWindow()
local f = win:frame()
f.x = f.x - 10
f.y = f.y - 10
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "K", function()
@steermomo
steermomo / fe.py
Created October 7, 2019 05:43
feature engineering
# https://www.kaggle.com/cdeotte/xgb-fraud-with-magic-0-9600
# Encoding Functions
# Below are 5 encoding functions.
# (1) encode_FE does frequency encoding where it combines train and test first and then encodes.
# (2) encode_LE is a label encoded for categorical features
# (3) encode_AG makes aggregated features such as aggregated mean and std
# (4) encode_CB combines two columns
# (5) encode_AG2 makes aggregated features where it counts how many unique values of one feature is within a group.
# For more explanation about feature engineering, see the discussion here
@steermomo
steermomo / python_pseudo_color.py
Created June 27, 2019 05:13
Python; Pseudo Color;将灰度图转为伪彩图;单色
from skimage import color
import numpy as np
def pseudo_color(arr: np.ndarray, hue: int):
"""生成伪彩图
:param arr: 灰度图像
:type arr: np.ndarray
:param hue: hsv空间的hue值, 用于指定颜色, 0~360
:type hue: int
import numpy as np
import keras
class DataGenerator(keras.utils.Sequence):
'Generates data for Keras'
def __init__(self, list_IDs, labels, batch_size=32, dim=(32,32,32), n_channels=1,
n_classes=10, shuffle=True):
'Initialization'
self.dim = dim
self.batch_size = batch_size
def hist_match(source, template):
"""
Adjust the pixel values of a grayscale image such that its histogram
matches that of a target image
Arguments:
-----------
source: np.ndarray
Image to transform; the histogram is computed over the flattened
array
import sys
def pretty_print(header,col, data, file=sys.stdout):
row_format ="{:<40}" + "{:<15}" * (len(header)) # format
print(row_format.format("", *header), file=file) # print header
for team, row in zip(col, data): # print data part
print(row_format.format(team, *row),file=file)
print('-' * (40 + 15 * len(header)), file=file) # print end line
import subprocess, re
# Nvidia-smi GPU memory parsing.
# Tested on nvidia-smi 370.23
def run_command(cmd):
"""Run command, return output as string."""
output = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).communicate()[0]
return output.decode("ascii")
from keras.utils.data_utils import OrderedEnqueuer
val_generator = DataGenerator(target=target, dataset_type='test', batch_size=12,
dim=img_dim, shuffle=False)
steps_per_epoch = len(val_generator)
val_enqueuer = OrderedEnqueuer(
val_generator,
use_multiprocessing=use_multiprocessing)
val_enqueuer.start(workers=workers,
max_queue_size=max_queue_size)
val_enqueuer_gen = val_enqueuer.get() # 无限循环 ref:https://github.com/keras-team/keras/blob/master/keras/engine/training_generator.py#L180
fuser -v /dev/nvidia* |awk '{for(i=1;i<=NF;i++)print "kill -9 " $i;}' | sh