Skip to content

Instantly share code, notes, and snippets.

View sontd-0882's full-sized avatar
🌴
On vacation

sontd-0882

🌴
On vacation
View GitHub Profile
@sontd-0882
sontd-0882 / mac-setup-redis.md
Created November 4, 2020 04:11 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@sontd-0882
sontd-0882 / master-javascript-interview.md
Created July 7, 2020 06:42 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series

Vanilla JS Event Delegation

Hôm nay chúng ta sẽ cùng thảo luận 1 tí về việc delegate event trong javascript (vanilla JS).

Chắc mọi người đã từng nghe qua khái niệm bubbling, đơn giản thôi:

When an element in the DOM is clicked, the event bubbles all the way up to the parent element (the document and then the window). This allows you to listen for events on the parent item and still detect clicks that happen inside it.

Hiểu nôm na là khi một sự kiện xảy ra trên DOM, các hàm handlers sẽ được gọi trên nó, sau đó đến parent element, đến document và cả window.

@sontd-0882
sontd-0882 / nginx-tuning.md
Created April 29, 2020 08:30 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@sontd-0882
sontd-0882 / japanese-font-family.md
Created April 23, 2020 08:14 — forked from vanquang9387/japanese-font-family.md
Japanese default css font family

Most Japanese websites use default font sets provided on Windows or Mac. The latest ones are Meiryo and Hiragino Kaku Gothic Pro. For older versions such like Windows XP, it is good to add former default fonts MS Gothic(or MS Mincho)/Osaka.

Some old browsers could not understand those font names in English, some others do not recognize the names in Japanese, so it is safe to write both in Japanese and English.

Meiryo and Hiragino's order is, because Mac users may have Meiryo from MS-Office, and Hiragino is more familiar and matching well on Mac, better by starting Hiragino series.

So the current recommended practice is like this,

font-family:"ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro",Osaka, "メイリオ", Meiryo, "MS Pゴシック", "MS PGothic", sans-serif;
@sontd-0882
sontd-0882 / script.ts
Created March 3, 2020 06:40
Listen child event from document
document.addEventListener('click', (event: Event) => {
const target = event.target as Element;
const button = target.closest('.btn');
if (!button) return;
const color = window
.getComputedStyle(button)
.getPropertyValue('background-color');
button.classList.add('ripple');
setTimeout(() => button.classList.remove('ripple'), 700);
@sontd-0882
sontd-0882 / deploy-pm2.md
Last active February 12, 2020 03:01 — forked from hoangmirs/deploy-pm2.md
Deploy pm2 guide

1. Preparing the server

Install git

sudo apt install git-all

Generate Server's SSH public key

ssh-keygen -t rsa -b 4096 -C "deploy"
cat ~/.ssh/id_rsa.pub
@sontd-0882
sontd-0882 / modifiers.scss
Created November 12, 2019 06:20 — forked from sarahdayan/modifiers.scss
Sass Modifiers Mixin
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
// Sass modifiers mixin by Sarah Dayan
// Generate All Your Utility Classes with Sass Maps: frontstuff.io/generate-all-your-utility-classes-with-sass-maps
// http://frontstuff.io
// https://github.com/sarahdayan
@sontd-0882
sontd-0882 / nginxproxy.md
Created November 11, 2019 07:31 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers