Skip to content

Instantly share code, notes, and snippets.

View anguschiu1's full-sized avatar

Angus Chiu anguschiu1

View GitHub Profile
@anguschiu1
anguschiu1 / openssl command.md
Last active January 20, 2020 07:38
openssl command #DNS #SSL #bash

Generate CSR

Provide SSL cert for that sub-domain, so we can apply to Bluemix.net and activate SSL (see attached example). Please notice that if the certificate need to be signed by external company, may take some time.

openssl req -new -sha256 -key ~/domain.com.ssl/domain.com.key -out ~/domain.com.ssl/domain.com.csr
openssl req -nodes -newkey rsa:2048 -keyout myserver.key -out server.csr

View certs

openssl x509 -in ssl_certificate.cer -text -noout
@anguschiu1
anguschiu1 / git_daily.md
Last active July 30, 2019 09:20
[Git tips] daily operation tips #git

How to get just several files/folders from another branch

git checkout master	# first get back to master
git checkout experiment doc/* app.js package.json	# then copy the version of files from branch "experiment"
git add . 
git commit -m "added something"

How to replace master branch in git, entirely, from another branch? [duplicate]

@anguschiu1
anguschiu1 / multi-git-repo.md
Last active June 3, 2018 15:25
[Quick Tip: How to Work with GitHub and Multiple Accounts] #git #ssh

Reference

Step 1 - Create a New SSH Key

We need to generate a unique SSH key for our second GitHub account.

ssh-keygen -t rsa -C "your-email-address"

Be careful that you don't over-write your existing key for your personal account. Instead, when prompted, save the file as id_rsa_COMPANY. In my case, I've saved the file to ~/.ssh/id_rsa_nettuts.

@anguschiu1
anguschiu1 / multiple_ssh_setting.md
Created December 19, 2017 03:10 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@anguschiu1
anguschiu1 / Syncing a fork.md
Last active December 19, 2017 03:35
[Syncing a fork] #git

Syncing a fork MAC WINDOWS LINUX Sync a fork of a repository to keep it up-to-date with the upstream repository.

Before you can sync your fork with an upstream repository, you must configure a remote that points to the upstream repository in Git.

Open Terminal.

Change the current working directory to your local project.

@anguschiu1
anguschiu1 / less.md
Last active December 19, 2017 08:46
[useful less command] #bash #less
@anguschiu1
anguschiu1 / beautify_bash.md
Created January 9, 2018 06:51
[Simple Tricks to Improve the Terminal Appearance in Mac OS X] #bash #CLI
@anguschiu1
anguschiu1 / nodejs_mem_leak.md
Last active February 23, 2018 10:07
[Handle memory leak of Node.js] #nodejs #javascript

Snippet to print out mem usage

logger.info(process.memoryUsage())

V8’s Memory Scheme

A running program is always represented through some space allocated in memory. This space is called Resident Set. V8 uses a scheme similar the Java Virtual Machine and divides the memory into segments:

  • Code: the actual code being executed
  • Stack: contains all value types (primitives like integer or Boolean) with pointers referencing objects on the heap and pointers defining the control flow of the program
  • Heap: a memory segment dedicated to storing reference types like objects, strings and closures.`
@anguschiu1
anguschiu1 / README-Template.md
Created April 14, 2018 15:20 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@anguschiu1
anguschiu1 / eaddrinuse.md
Last active July 17, 2018 08:05
[ How to solve nodejs Error: listen EADDRINUSE ] #bash #CLI

Method 1

You can check using netstat -an that is there any process running on 8080 or not.

Method 2

On macOS High Sierra, use this command:

lsof -nP -i4TCP:$PORT | grep LISTEN

On older versions, use one of the following forms: