Skip to content

Instantly share code, notes, and snippets.

View nguyenhuutuananh's full-sized avatar
🛠️
Fighting

Tuân Anh Nguyễn nguyenhuutuananh

🛠️
Fighting
View GitHub Profile
@nguyenhuutuananh
nguyenhuutuananh / 01-setup_docker_al2023.md
Created March 5, 2024 18:13 — forked from thimslugga/setup-docker-al2023.md
Setup Docker and docker-compose on Amazon Linux 2023

Setup Docker on Amazon Linux 2023

Steps to Install and Setup Docker on Amazon Linux 2023

Install the packages

Install the following packages, which are good to have installed:

sudo dnf install --allowerasing -y dnf-plugins-core \
@nguyenhuutuananh
nguyenhuutuananh / split-string-by-delimiter.sh
Created January 13, 2023 01:02
Bash - Split string by delimiter
#!/bin/bash
awk -F':' '{ for(i=1;i<=NF;i++) print $i }' <<< $PATH
@nguyenhuutuananh
nguyenhuutuananh / short-number-format.php
Created December 3, 2021 09:41 — forked from RadGH/short-number-format.php
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
@nguyenhuutuananh
nguyenhuutuananh / event-loop.md
Created December 22, 2020 07:44 — forked from jesstelford/event-loop.md
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

@nguyenhuutuananh
nguyenhuutuananh / test.js
Created October 26, 2020 06:45 — forked from jmyrland/test.js
Socket-io load test?
/**
* Modify the parts you need to get it working.
*/
var should = require('should');
var request = require('../node_modules/request');
var io = require('socket.io-client');
var serverUrl = 'http://localhost';
@nguyenhuutuananh
nguyenhuutuananh / jwt-expiration.md
Created July 28, 2020 09:45 — forked from soulmachine/jwt-expiration.md
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC: