Skip to content

Instantly share code, notes, and snippets.

View soomtong's full-sized avatar
😇

YoungTaek soomtong

😇
View GitHub Profile
@soomtong
soomtong / gcp-global-lb-multi-region-cr-ce.sh
Created April 12, 2024 04:26 — forked from mikesparr/gcp-global-lb-multi-region-cr-ce.sh
Demonstrating how you can deploy Cloud Run (serverless) or Compute Engine instance groups across regions and balance with global load balancer
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/run/docs/multiple-regions
# - https://cloud.google.com/compute/docs/instance-groups/distributing-instances-with-regional-instance-groups
# - https://cloud.google.com/load-balancing/docs/https/setup-global-ext-https-compute
# - https://cloud.google.com/load-balancing/docs/backend-service#named_ports
#####################################################################
@soomtong
soomtong / nodejs-on-exit.js
Created May 12, 2023 14:14 — forked from hyrious/nodejs-on-exit.js
how to do something before exit in NodeJS
// only works when there is no task running
// because we have a server always listening port, this handler will NEVER execute
process.on("beforeExit", (code) => {
console.log("Process beforeExit event with code: ", code);
});
// only works when the process normally exits
// on windows, ctrl-c will not trigger this handler (it is unnormal)
// unless you listen on 'SIGINT'
process.on("exit", (code) => {
@soomtong
soomtong / dot.vimrc
Last active April 16, 2023 14:41
vanilla vim rc file
let mapleader="\<SPACE>"
inoremap jk <ESC>
nnoremap <SPACE> <Nop>
nnoremap <Leader>w :wa<CR>
nnoremap <leader>q :qa<Enter>
nnoremap <leader>h :set hlsearch! hlsearch?<CR>
" Buffer
nnoremap <Tab> :bnext!<Enter>
nnoremap <S-Tab> :bprevious!<Enter>
@soomtong
soomtong / geometry.el
Last active April 3, 2021 13:11 — forked from synic/geometry.el
(defun save-framegeometry ()
"Gets the current frame's geometry and saves to ~/.emacs.d/framegeometry."
(let (
(framegeometry-left (frame-parameter (selected-frame) 'left))
(framegeometry-top (frame-parameter (selected-frame) 'top))
(framegeometry-width (frame-parameter (selected-frame) 'width))
(framegeometry-height (frame-parameter (selected-frame) 'height))
(framegeometry-file (expand-file-name "~/.emacs.d/framegeometry"))
)
/*
Proof of concept: Writing dual-mode (sync and async) code via generators
Recommendation: start by reading the example (at the end).
API:
– The API object is called `def`.
– Dual-mode `await`: const unwrapped = yield wrapped;
– Dual-mode `yield`: yield def.$one(singleValue)
– Dual-mode `yield*`: yield def.$all(iterable)
@soomtong
soomtong / config.el
Last active January 16, 2021 07:34
doom emacs config file
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "YoungTaek Joo"
user-mail-address "soomtong@gmail.com")
@soomtong
soomtong / simple-zsh-env.md
Last active December 13, 2021 22:27
simple zsh setup guide
@soomtong
soomtong / hhkb.json
Last active April 1, 2022 15:27
happy hacking keyboard layout for macOS karabiner
{
"title": "HHKB for macOS",
"rules": [
{
"description": "shift + esc to tilde",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "escape",
@soomtong
soomtong / encryption.js
Created April 2, 2020 06:36 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@soomtong
soomtong / gk888b.json
Created December 13, 2019 07:28
GK888B key layout for macOS
{
"title": "GK888B for macOS",
"rules": [
{
"description": "capslock to f16",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock"