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 / how_to_install_gem_idn-ruby.md
Created September 13, 2018 11:01
How to install gem idn-ruby

How to install gem idn-ruby

Ubuntu*

$ sudo apt -y install libidn11-dev
$ gem install idn-ruby  # Rails で使用する場合はプロジェクトディレクトリ内で bundle install

macOS

@ntamvl
ntamvl / tip-upgrade-ruby-to-new-version.md
Last active December 26, 2018 03:32
Tip upgrade Ruby to new version

First, install latest Ruby Example:

rbenv install 2.6.0
rbenv global 2.6.0
rbenv rehash

After that I redid the following:

@ntamvl
ntamvl / install-squid-proxy-server-on-ubuntu-14-04.md
Last active January 6, 2019 08:52
Install Squid proxy server on Ubuntu 14.04

Install Squid proxy server on Ubuntu 14.04

Installing Squid

Squid is available in the Ubuntu repositories. To ensure your system is up to date and then to install Squid, run the following commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install squid

Copy the original configuration file to keep as a backup:

@ntamvl
ntamvl / os-x-terminal-color-prompt.md
Last active May 6, 2019 01:52
OS X Terminal color prompt

OS X Terminal color prompt

Update .bash_profile with content:

export CLICOLOR=1
export PS1="\[\e[36m\]\w\[\e[0m\]$ "
alias ll='ls -GFhl' dir='ls -GFhl'
alias start=open
printf "\033]0;`date "+%a %d %b %Y %I:%M %p"`\007"
@ntamvl
ntamvl / compress-multiple-folders-each-into-its-own-zip-archive.md
Last active July 3, 2019 10:28
Compress multiple folders, each into its own zip archive

Compress multiple folders, each into its own zip archive

for i in */; do tar -czvf "${i%/}.tar.gz" "$i"; done

Example:

for i in */; do 
@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 / on-macos-mojave-rbenv-install-261-hangs-at-use-realline-from-homebrew.md
Last active May 2, 2020 18:20
On macOS Mojave, rbenv install 2.6.1 hangs at "use realline from homebrew"

On macOS Mojave, rbenv install 2.6.1 hangs at "use realline from homebrew"

First install readline from homebrew

brew install readline
brew link --force readline

This fixed it for me:

@ntamvl
ntamvl / remove-all-node_module-folders-recursively.md
Last active May 2, 2020 18:21
Remove all node_module folders recursively

Remove all node_module folders recursively

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

That will delete the folder and files even if there is a space in the name.

That saved me about 10GB over several hundred node projects which I had not touched in a while. If I need the node modules back, I can simply run npm install

@ntamvl
ntamvl / systemd_service_for_homebridge.md
Last active June 26, 2020 07:07
Systemd Service for homebridge on Raspberry Pi (http://github.com/nfarina/homebridge)

Systemd Service for homebridge on Raspberry Pi

Check location of homebridge

pi@raspberrypi:~/.homebridge $ which homebridge
/usr/bin/homebridge

Create file /etc/systemd/system/homebridge.service

@ntamvl
ntamvl / ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md
Last active July 26, 2021 10:06
Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )

Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )

If you are setting up nginx,chances are you will discover your worker_connections is at some low number, such as 1024. You can’t increase this number unless you increase kernel limit as well. First of all run cat /proc/sys/fs/file-max to discover your maximum limit.

abc@ubuntu:~$ cat /proc/sys/fs/file-max
1048576
abc@ubuntu:~$ ulimit -n
1024