Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Tam Nguyen ntamvl

🏠
Working from home
View GitHub Profile
@ntamvl
ntamvl / ffmpeg-convert-edit-video-via-command-line.md
Last active Feb 23, 2021
FFMPEG: Convert & Edit Video via Command Line
View ffmpeg-convert-edit-video-via-command-line.md

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 Jun 26, 2020
Systemd Service for homebridge on Raspberry Pi (http://github.com/nfarina/homebridge)
View systemd_service_for_homebridge.md

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 Dec 4, 2020
Example: use aws-sdk-mock to test AWS SSM
View example-use-aws-sdk-mock-to-test-aws-ssm.md

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 Jul 3, 2019
Compress multiple folders, each into its own zip archive
View compress-multiple-folders-each-into-its-own-zip-archive.md

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 Mar 3, 2021
How to create a Ruby gem that adds Rake tasks
View create-ruby-gem-that-adds-rake-tasks.md

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 Jun 3, 2019
How to update/add a file in the Docker Image
View how-to-update-add-a-file-in-the-docker-image.md

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
OS X Terminal color prompt
View os-x-terminal-color-prompt.md

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
On macOS Mojave, rbenv install 2.6.1 hangs at "use realline from homebrew"
View on-macos-mojave-rbenv-install-261-hangs-at-use-realline-from-homebrew.md

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 May 2, 2020
Remove full path from terminal
View remove-full-path-from-terminal.md

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,
@ntamvl
ntamvl / docker-remove-all-images-containers.md
Last active Feb 14, 2019
Docker: Remove All Images and Containers
View docker-remove-all-images-containers.md

Docker: Remove All Images and Containers

Starting over in this case means wiping clean my Docker images and containers, just to make sure there are no conflicts or duplicates. The following commands delete all containers and images:

Delete every Docker containers Must be run first because images are attached to containers

docker rm -f $(docker ps -a -q)

Delete every Docker image