Skip to content

Instantly share code, notes, and snippets.


Robert Zhang coin8086

  • @Azure Microsoft
  • Shanghai, China
View GitHub Profile
coin8086 /
Last active Apr 19, 2021
TLS in a Nutshell

TLS in a Nutshell


  • What's TLS?
  • TLS Protocol
  • TLS Implementation

What's TLS?


Ubuntu VS CentOS

Package Management

Ubuntu CentOS
Search package that contains the file dpkg -S <file> rpm -qf <file>
List package files dpkg -L <package> rpm -ql <package>
Search packages with glob pattern dpkg -l <pattern> rpm -qa <pattern>
Show package info dpkg -s <package> / dpkg -p <package> rpm -qi <package>
coin8086 /
Created Mar 1, 2019
Git on Windows: File EOL and Permission Mode

Git on Windows: File EOL and Permission Mode

coin8086 /
Last active Mar 1, 2019
Docker command line completion in Bash

Docker Command Line Completion in Bash


  1. Make sure bash completion is installed(It's installed by default in major Linux distributions, and Cygwin).
  2. Put completion files to /etc/bash_completion.d/

Completion Files


Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocal you use. And there're two common protocals: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocal. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
View gist:488580e650a552bdfbd0f858c193a26e

Compile C++ REST SDK on CentOS 7

C++ REST SDK is built on Ubuntu 16 by the offical document. To build it on CentOS 7, here's how.


  1. Install build tools by sudo yum group install Development\ Tools
  2. Install dependent libraries by sudo yum install zlib-devel libicu-devel openssl-devel
  3. Get CMake 3.x binary from
  4. Get Boost 1.58 source code from and install it under /opt/boost_1_58_0 by
coin8086 /
Last active Apr 20, 2018
Getting Start on REST​

Getting Start on REST

A Simple Definition

REST is a style and a set of guide lines for web service, such as web API.


  • is resource oriented
  • uses HTTP method to convey method information
  • uses URL to scope the resource to operate on

Raspberry Pi NAS Server Getting Start

Install Raspbian OS

Get the OS image file(RASPBIAN STRETCH LITE) from, and write it into a SD card as said by

Config for Remote Access


Git Notes


  1. Windows Git client sets core.ignorecase to true by default, you may need to disable it to detect server changes on file names. Check it by git config --get core.ignorecase, and set it by git config core.ignorecase false.
  2. Detect file EOL by git grep -I '^M'. It searches for a literal CR character in files.


  1. To git show more lines before and after the changed lines, use git show -U <NUM>.
  2. To git diff a file/dir between two commits, use git diff <first-commit> <second-commit> [--] <filepath>. Either commit can be omitted, in which case it's as if HEAD is used for that omitted commit.
coin8086 /
Last active Dec 27, 2018
Bulk insert/upsert method for ActiveRecord on PostgreSQL(9.5 and later)

ActiveRecord Bulk Write Patch


Suppose there's a table

create table users (
  id integer primary key,
  name text,