Skip to content

Instantly share code, notes, and snippets.

View ntamvl's full-sized avatar
🏠
Working from home

Tam Nguyen ntamvl

🏠
Working from home
View GitHub Profile
@ntamvl
ntamvl / SOCKS-5-proxy-tunnel.md
Last active February 21, 2024 11:10
SOCKS 5 proxy tunnel

SOCKS 5 proxy tunnel

Open a terminal program on your computer. On Mac OS X, this is Terminal in Applications > Utilities.

Set up the tunnel with this command:

ssh -D 8123 -f -C -q -N ubuntu@example.com

Explanation of arguments

@ntamvl
ntamvl / run_react_native_application_on_ios_device_directly_from_command_line.md
Created July 5, 2018 04:44
Run react-native application on iOS device directly from command line

Run react-native application on iOS device directly from command line

The following worked for me (tested on react native 0.38 and 0.40):

npm install -g ios-deploy
# Run on a connected device, e.g. Max's iPhone:
react-native run-ios --device "Max's iPhone"

This is the proper way to do this according to fb. If you try to run just the run-ios command, you will find that the script recommends that you npm install -g ios-deploy when it comes to the install step after building.

@ntamvl
ntamvl / remove-all-node_module-folders-recursively.md
Last active February 21, 2024 11:10
Remove all node_module folders recursively

Remove all node_module folders recursively

With any type of folder/file

find . -name "node_modules" -exec rm -rf '{}' +

Only folder

find . -type d -name "node_modules" -exec rm -rf '{}' +
@ntamvl
ntamvl / Max-value-decimal-in-PostgreSQL-scale-and-length.md
Last active February 21, 2024 11:10
Max value decimal in PostgreSQL

Max value decimal in PostgreSQL

Calculate from precision, scale, and length

max_value = 10^(precision - scale)
@ntamvl
ntamvl / how-to-avoid-duplicate-api-requests-with-redux-saga.md
Last active February 21, 2024 11:10
[Redux Saga] Deduplicate request

How to avoid duplicate API requests with Redux-Saga?

Also it might be a good to decouple your saga from the state shape itself, im alway trying to do this, unless it would provide to copying reducers' logic in your sagas.

You could create a higher order saga for this, which would look something like this:

function* takeOneAndBlock(pattern, worker, ...args) {
  const task = yield fork(function* () {
    while (true) {
 const action = yield take(pattern)
@ntamvl
ntamvl / how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04.md
Last active April 15, 2020 06:55
How To Secure Nginx with Let's Encrypt on Ubuntu 16.04

How To Secure Nginx with Let's Encrypt on Ubuntu 16.04

Step 1 — Installing Certbot

First, add the repository.

sudo add-apt-repository ppa:certbot/certbot

You'll need to press ENTER to accept. Then, update the package list to pick up the new repository's package information.

sudo apt-get update
@ntamvl
ntamvl / react-native-vector-icons-error.md
Created June 6, 2018 04:01
Error: While resolving module `react-native-vector-icons/MaterialIcons`, the Haste package `react-native-vector-icons` was found

Error: While resolving module react-native-vector-icons/MaterialIcons, the Haste package react-native-vector-icons was found

The file it is trying to find does in fact declare that module.

This is why it breaks now: facebook/metro#139 (comment)

Related issue: #379

@ntamvl
ntamvl / parallels_tools_ubuntu_new_kernel_fix.md
Created May 30, 2018 02:05 — forked from rudolfratusinski/parallels_tools_ubuntu_new_kernel_fix.md
Parallels Tools fix for Ubuntu 18.04 and other Linux distributions with Kernel version >= 4.15

Preparation

  • In open Ubuntu 18.04 machine click Parallels Actions -> "Install Parallels Tools"

  • A "Parallels Tools" CD will popup on your Ubuntu desktop.

  • Open it by double mouse click, copy all the content to a new, empty directory on a desktop, name it for e.g. "parallels_fixed"

  • Open terminal, change directory to parallels_fixed (cd ~/Desktop/parallels_fixed)

  • Make command line installer executable (chmod +x install)

  • Change directory to "installer" (cd installer)

  • Make few other scripts executable: chmod +x installer.* *.sh prl_*

@ntamvl
ntamvl / robot_tranh_vat_can_v1.ino
Created May 17, 2018 01:47
Arduino - Robot tránh vật cản
/***
* Description: Just for ...
* Email: ntamvl@gmail.com
***/
#include <AFMotor.h>
#include <Servo.h>
#define TRIG_PIN A4
#define ECHO_PIN A5
@ntamvl
ntamvl / disk-speed-test-read-write-hdd-ssd-perfomance-linux.md
Created May 4, 2018 08:25
Disk Speed Test (Read/Write): HDD, SSD Performance in Linux

Disk Speed Test (Read/Write): HDD, SSD Performance in Linux

From this article you’ll learn how to measure an input/output performance of a file system on such devices as HDD, SSD, USB Flash Drive etc.

I’ll show how to test the read/write speed of a disk from the Linux command line using dd command.

I’ll also show how to install and use hdparm utility for measuring read speed of a disk on Linux Mint, Ubuntu, Debian, CentOS, RHEL.

Take the average result: To get the accurate read/write speed, you should repeat the below tests several times (usually 3-5) and take the average result.