Skip to content

Instantly share code, notes, and snippets.

View tanhit243's full-sized avatar
💭
I may be slow to respond.

Vu Tuan Anh tanhit243

💭
I may be slow to respond.
View GitHub Profile
# Show firewall
sudo ufw status verbose
# Open port
Nếu bạn muốn mọi người trên internet truy cập được vào máy chủ của bạn thì bạn cần mở port trong firewall để cho phép họ truy
thông qua port vừa mở.
sudo ufw allow 22/tcp
# List open port
Kiểm tra model có bị lỗi abc trên thuộc tính xyz trong rails
model.errors.of_kind? :xyz, :abc //true or false
@tanhit243
tanhit243 / gist:cf7dbec0e08af205ecb805e8d1660499
Created December 25, 2021 03:44 — forked from mrtns/gist:78d15e3263b2f6a231fe
Upgrade Chrome from Command Line on Ubuntu
# Install
# via http://askubuntu.com/questions/510056/how-to-install-google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
# Update
Command to add public key from local to server
ssh-copy-id -i public_key_file_name user@server
Use cmd: dmesg,
You can use grep, tail, less
dmesg | tail -n 30
unzip file.zip -d dir_path
tar to extract files from a tarball with option directory
tar -zxvf Project4x.tar.gz -C dir_path
THOR_MERGE="code -d $1 $2" rails new . -d mysql
@tanhit243
tanhit243 / README.md
Created August 2, 2022 03:26 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

https://ruby-doc.org/stdlib-3.1.2/libdoc/English/rdoc/English.html