Skip to content

Instantly share code, notes, and snippets.

View kemingy's full-sized avatar
🈚
actions

Keming kemingy

🈚
actions
View GitHub Profile
@kemingy
kemingy / wezterm.lua
Last active November 23, 2022 02:12
config for wezterm (wsl)
local wezterm = require 'wezterm';
function recompute_padding(window)
local window_dims = window:get_dimensions();
local overrides = window:get_config_overrides() or {}
if not window_dims.is_full_screen then
if not overrides.window_padding then
-- not changing anything
return;
@kemingy
kemingy / calligraphy.md
Last active August 29, 2021 05:39
Chinese Calligraphy

三要素

  • 用笔--五执笔+九用
  • 识势--永字八法+五势
  • 裹束--大圈+小圈

主要书体

@kemingy
kemingy / python_local_patch_process.py
Last active January 21, 2021 13:01
fork will share the current state, spawn will reimport and rebuild everything
import os
import multiprocessing as mp
data = {
"msg": "hello world",
}
class Demo:
@kemingy
kemingy / argparse_duration_to_seconds.py
Last active December 10, 2020 08:42
python argparser customized duration type
def duration_to_seconds(duration: str):
"""convert duration string to seconds"""
unit_to_seconds = {
"ns": 1e-9,
"µs": 1e-6,
"ms": 1e-3,
"s": 1,
"m": 60,
"h": 3600,
}
@kemingy
kemingy / pickle_numpy_benchmark.py
Created November 11, 2020 03:18
pickle is just very slow...
import pickle
import numpy as np
img = np.random.rand(3, 1000, 1000)
data = img.tobytes()
def dump(arr):
return pickle.dumps((arr.tobytes(), arr.dtype, arr.shape))

crontab

ps aux | grep crond

  • minute / hour / day of month / month / day of week / user / command
  • * means all, */n means every n
  • * * * * * user /path/to/cronscripts.sh >> /tmp/cron.log 2>&1 redirects STDERR to STDOUT
@kemingy
kemingy / os_basic.md
Created October 26, 2020 15:59
OS related questions for interview

Synchronization Primitives

Mutex vs Semaphore

  • mutex
    • locking mechanism
    • only the owner can release the lock
    • recursive mutex can be locked more than once (POSIX complaint systems)
  • semaphore
  • signaling mechansim
@kemingy
kemingy / network.md
Created October 26, 2020 15:18
network note
@kemingy
kemingy / mysql.md
Created October 25, 2020 16:27
interview questions for mysql
@kemingy
kemingy / README.md
Created October 15, 2020 11:44
pyarrow IPC socket