Skip to content

Instantly share code, notes, and snippets.

View doraeminemon's full-sized avatar
🎯
Focusing

Do Dinh Thy Son doraeminemon

🎯
Focusing
View GitHub Profile
@doraeminemon
doraeminemon / nonAccentVietnamese.js
Last active October 27, 2022 02:58 — forked from jarvisluong/nonAccentVietnamese.js
Converting standard Vietnamese Characters to non-accent ones. Example: hải -> hai
function nonAccentVietnamese(str) {
str = str.replace(/A|Á|À|Ã|Ạ|Â|Ấ|Ầ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẵ|Ặ/g, "A");
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
str = str.replace(/E|É|È|Ẽ|Ẹ|Ê|Ế|Ề|Ễ|Ệ/, "E");
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
str = str.replace(/I|Í|Ì|Ĩ|Ị/g, "I");
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
str = str.replace(/O|Ó|Ò|Õ|Ọ|Ô|Ố|Ồ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ỡ|Ợ/g, "O");
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
str = str.replace(/U|Ú|Ù|Ũ|Ụ|Ư|Ứ|Ừ|Ữ|Ự/g, "U");
@doraeminemon
doraeminemon / solution.js
Created October 8, 2021 07:07
3Sum best solution
/**
* @param {number[]} nums
* @return {number[][]}
*/
var threeSum = function(nums) {
if (nums.length < 3) {
return []
}
const result = []

Problem

  • Migration taking too long to completed, put pressure on CPU & causing problem on deployment
  • Default backfill meaning that PG will try to update all old orders at once. As DB grows, the pain will grow also.

Solution

  • is it wht we will recommend as a pattern later? wht is the conclusion, we never do NOT NULL in SQL level and only do default in model?
  • plan to fill up existing value if we adopt this pattern? or plan to leave them NULL but handle by Scan etc, as a pattern we recommend?
  • Any other options u considered before jumping into conclusion and a “fix” like this?

Other options to considered :

  • Setting longer readiness waiting time for K8s → Can cause actual failure took longer to be fixed
@doraeminemon
doraeminemon / README.md
Last active July 18, 2019 07:30
Deployment with SSL, NGINX, docker-compose checklist

Deployment with SSL checklist

  • Mapped domain to server's IP
  • SSH to server and run generate_cert.sh ( dry-run first, then actual )
  • Copy cert file to accessible location by nginx
  • Config nginx location correctly to cert and to proxy server
  • Config docker-compose file to complete this checklist :
  • Service name and port mapping matched nginx.conf
  • Dockerize so that nginx wait for service to come up
  • Additional CORS header config in server and nginx.conf
  • Docker-compose up -d on server
@doraeminemon
doraeminemon / .zshrc
Last active July 31, 2020 08:24
My backup.zshrc file
source ~/.zsh/antigen.zsh
export LANG=en_US.UTF-8
export SSH_KEY_PATH="~/.ssh/rsa_id"
antigen use oh-my-zsh
CASE_SENSITIVE="true"
COMPLETION_WAITING_DOTS="true"
BASE16_SHELL="$HOME/.config/base16-shell/"
@doraeminemon
doraeminemon / GoogleDOB.swift
Created December 22, 2017 10:04
How to get user info with birthday from GoogleSignIn
// Về cơ bản, đầu tiên có được access sau khi sử dụng Gooogle SDk
// Trong Google SDK cần 1 sô thành phần để tiếp tục :
// - user.authentication.accessToken
// - user.userID
// - user.authentication.idToken
///
/// Dùng để lấy tât cả mọi trương trừ DOB
///
struct TokenInfo : TargetType {
@doraeminemon
doraeminemon / READ.md
Last active January 2, 2017 13:16
Code reading process of AsyncDisplayKit library ( github/facebook/asyncdisplaykit )

Pre-words

This is a description of the though process of me, how I'm going through the code of the AsyncDisplayKit library in order to try to understand it. The current knowledge level of me when I'm reading this :

  • Swift : intermediate / post-intermediate
  • Objectice-C : intermediate
  • C++ / C : mediocre

I'm going to describe the order of the files I'm reading and why. In each and every file, I'm going to describe :

  • Unknown import : These will be due until I can't explain what the class is doing within my depth of knowledge. Otherwise explain and educated guess.
  • Unknown structure : These structure will need to be googled and explain right away.