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 / 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 / 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 / git-tag-delete-local-and-remote.sh
Created October 3, 2019 06:45 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@soomtong
soomtong / index.js
Created June 21, 2019 01:32 — forked from junosuarez/index.js
async cli app boilerplate
#!/usr/bin/env node
if (process.mainModule === module) setImmediate(() => main(process.argv).catch(e => console.log(e.stack) && process.exit(1)))
async function main(argv) {
console.log(argv.slice(2))
}
@soomtong
soomtong / korean_marker.rb
Created February 16, 2019 11:41 — forked from elegantcoder/korean_marker.rb
한글 은/는, 이/가 (Powered by ActiveSupport::Multibyte::Chars)
# require 'active_support/all'
def korean_topic_marker(str)
k = str[-1] # last one char
return '는' if k.mb_chars.decompose.size < 3 # 종성이 없는 경우
return '은'
end
def korean_subject_marker(str)
k = str[-1] # last one char
@soomtong
soomtong / mac-keycodes
Created February 14, 2019 12:27 — forked from eegrok/mac-keycodes
Mac virtual keycodes
from: http://www.meandmark.com/keycodes.html
Virtual Keycodes for the Mac QWERTY Layout
Keycodes are in hexadecimal. A blank entry means either there is no key assigned to that keycode or I was unable to find the assigned key.
Keycode Key
0x00 A
0x01 S
0x02 D
0x03 F
@soomtong
soomtong / 한글과유니코드.md
Created November 26, 2018 09:47 — forked from Pusnow/한글과유니코드.md
한글과 유니코드

한글과 유니코드

유니코드에서 한글을 어떻게 다루는지를 정리하였다.

유니코드

  • 유니코드(Unicode)는 전 세계의 모든 문자를 컴퓨터에서 일관되게 표현하고 다룰 수 있도록 설계된 산업 표준 (위키 백과)
  • 단순히 문자마다 번호를 붙임
  • 계속 업데이트되며 현재는 Unicode Version 9.0.0 이 최신이다.

UTF

  • 유니코드를 실제 파일 등에 어떻게 기록할 것인지를 표준화한 것이다.