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 / Use Sweetalert2 on Rails 7.md
Last active April 10, 2024 14:17
Use Sweetalert2 on Rails 7

Use Sweetalert2 on Rails 7

Install sweetalert2 package

yarn add sweetalert2

OR if you use importmap

./bin/importmap pin sweetalert2
@ntamvl
ntamvl / ffmpeg-convert-edit-video-via-command-line.md
Last active January 18, 2023 03:29
FFMPEG: Convert & Edit Video via Command Line

FFMPEG: Convert & Edit Video via Command Line

FFMPEG is a free software that lets you create/edit/convert videos via command line. You can download and install FFMPEG for Linux, Windows, and Mac Operating System.

FFMPEG provides a lot of features that you can apply to an video like:

– get detailed information of the video
– record video
– convert video to audio
– convert video from one format to another
@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 / example-use-aws-sdk-mock-to-test-aws-ssm.md
Last active February 17, 2023 15:56
Example: use aws-sdk-mock to test AWS SSM

Use aws-sdk-mock to test AWS SSM

Example:

const AWSMock = require("aws-sdk-mock");
import AWS = require("aws-sdk");
AWSMock.setSDKInstance(AWS);

import "mocha";
@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 / create-ruby-gem-that-adds-rake-tasks.md
Last active February 16, 2024 19:13
How to create a Ruby gem that adds Rake tasks

How to create a Ruby gem that adds Rake tasks

Create a gem

One way to do this is to use bundler to scaffold our gem:

bundler gem my_gem

Add rake tasks to our gem

I prefer to put tasks meant to manage the gem itself in lib/tasks, and tasks the gem is meant to provide to gem users in lib/my_gem/tasks.

@ntamvl
ntamvl / how-to-update-add-a-file-in-the-docker-image.md
Last active February 21, 2024 11:09
How to update/add a file in the Docker Image

How to update/add a file in the Docker Image

The post discusses how to alter a standard docker image pulled from a Public repository in Docker hub as per your need. For the example of this post, we will pull a latest CentOS docker image and add a test directory test_dir and create a test file test_file into it.

Adding a directory and image in the docker image

  1. First step is to pull a latest CentOS image from docker hub.
# docker pull centos
Using default tag: latest
@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 / 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-full-path-from-terminal.md
Last active February 21, 2024 11:09
Remove full path from terminal

Remove full path from terminal

The part before the $ in a shell is called prompt. It can be configured by changing the variable $PS1. There are is a similar question with good answeres.

The man page (see "Bash" and there "PROMPTING") says:

      \w     the  current working directory, with $HOME
             abbreviated with a tilde (uses the value of the
             PROMPT_DIRTRIM variable)
 \W the basename of the current working directory,