Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Tam Nguyen ntamvl

🏠
Working from home
Block or report user

Report or block ntamvl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ntamvl
ntamvl / example-use-aws-sdk-mock-to-test-aws-ssm.md
Last active Jul 4, 2019
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 Jun 27, 2019
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 Mar 10, 2019
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 Mar 10, 2019
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

@ntamvl
ntamvl / list-of-chrome-driver-command-line-arguments.md
Created Jan 30, 2019
List of Chrome Driver command line arguments
View list-of-chrome-driver-command-line-arguments.md

List of Chrome Driver command line arguments

Here is the list of Chrome Driver command line Arguments.

If you are using chrome Driver for Selenium WebDriver or Protractor or …. then these are a handy useful list of command line arguments that can be used.

You may use this to look at the usuage: https://code.google.com/p/chromium/codesearch#chromium/src/chromeos/chromeos_switches.cc

Run chromedriver –help to see command line arguments for your version.

@ntamvl
ntamvl / tip-upgrade-ruby-to-new-version.md
Last active Dec 26, 2018
Tip upgrade Ruby to new version
View tip-upgrade-ruby-to-new-version.md

First, install latest Ruby Example:

rbenv install 2.6.0
rbenv global 2.6.0
rbenv rehash

After that I redid the following:

You can’t perform that action at this time.