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 / install-multiple-jdk-on-macos-high-sierra.md
Last active Nov 21, 2019
Install Multiple Java Versions on macOS High Sierra
View install-multiple-jdk-on-macos-high-sierra.md

Install Multiple Java Versions on macOS High Sierra

Install Homebrew Cask

On Mac, Homebrew is the de-facto package manager, and Homebrew Cask is the app manager. I’m going to use Cask to install Java 7 and 8.

Install Homebrew Cask first if you haven’t:

brew update
brew tap caskroom/cask
@ntamvl
ntamvl / ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md
Last active Nov 14, 2019
Ubuntu 16 – how to increase maximum file open limit ( ulimit -n )
View ubuntu-16-increase-maximum-file-open-limit-ulimit-n.md

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
@ntamvl
ntamvl / cant-install-rmagick-2-13-1-cant-find-magickwand-h.md
Last active Oct 22, 2019
[Resolved In Mac OSX Sierra] Can't install RMagick 2.13.1. Can't find MagickWand.h.
View cant-install-rmagick-2-13-1-cant-find-magickwand-h.md

[Resolved] Can't install RMagick 2.13.1. Can't find MagickWand.h

In Mac OSX Sierra, to solve the issue, I had to do the following:

Clean:

brew uninstall imagemagick
brew unlink imagemagick

Then install:

@ntamvl
ntamvl / systemd_service_for_homebridge.md
Last active Aug 29, 2019
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 / getting_a_readable_text_in_iterm2_how_do_i_color.md
Last active Jul 31, 2019
iTerm2 - color 'ls' and other outputs for MacOS
View getting_a_readable_text_in_iterm2_how_do_i_color.md

iTerm2 - color 'ls' and other outputs for MacOS

That's right. For OS X and BSD's ls, the flag is -G. Many people customize the behavior of ls by replacing it with an alias that adds extra options. I have the following in my .bashrc, for example:

alias ls='LSCOLORS=gxfxcxdxbxexexabagacad /bin/ls -bFHGLOPW'

Besides enabling colors in general, this sets the LSCOLORS variable in order to change which ones ls uses.

@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"
You can’t perform that action at this time.