Skip to content

Instantly share code, notes, and snippets.

View zhiguangwang's full-sized avatar

Zhiguang Wang zhiguangwang

View GitHub Profile
@zhiguangwang
zhiguangwang / .bash_aliases
Created April 24, 2016 13:59
Convenient aliases to list TCP listeners and connections on Ubuntu
alias netls='sudo netstat -plant | grep LISTEN'
alias netls4='sudo netstat -4 -plant | grep LISTEN'
alias netls6='sudo netstat -6 -plant | grep LISTEN'
alias netlsc='sudo netstat -plant | grep -v LISTEN'
alias netlsc4='sudo netstat -4 -plant | grep -v LISTEN'
alias netlsc6='sudo netstat -6 -plant | grep -v LISTEN'
alias netlsa='sudo netstat -plant'
@zhiguangwang
zhiguangwang / README.md
Created April 27, 2016 03:41
Find all shell scripts and add execute permissions to all of them.
find . -name "*.sh" -exec chmod u+x {} \;
@zhiguangwang
zhiguangwang / git-repo-init.sh
Created July 19, 2016 12:07
Clone, init and pull git repository with multiple submodules.
git lfs clone --recursive [repo].git
git submodule foreach git lfs pull
@zhiguangwang
zhiguangwang / bashrc.bat
Last active July 26, 2016 10:40
batch file to initialize windows command line environment (equivalent with .bashrc)
@echo off
set HOME=%HOMEDRIVE%%HOMEPATH%
@rem Utilites
set PATH=%PATH%;C:\Program Files\WinRAR
set PATH=%PATH%;C:\Program Files (x86)\Microsoft VS Code\bin
set PATH=%PATH%;%HOME%\apps\cmake\3.6.0-win64-x64\bin
set PATH=%PATH%;%HOME%\apps\bin
@zhiguangwang
zhiguangwang / optional.cpp
Created September 29, 2017 04:19
sizeof std::optional<T>
#include <iostream>
#include <string>
#include <optional>
int main()
{
std::cout << "sizeof bool is " << sizeof(bool) << '\n';
std::cout << "sizeof std::optional<bool> is " << sizeof(std::optional<bool>) << "\n\n";
std::cout << "sizeof short is " << sizeof(short) << '\n';
@zhiguangwang
zhiguangwang / ec2-ping-test.sh
Last active April 11, 2018 07:25
Testing latency between regions.
#!/bin/bash
#
# Usage:
#
# 1. Set SECURITY_GROUP and KEY_NAME to your value
# 2. source ec2-ping-test.sh
# 3. launch_all_instances
# 4. terminate_all_instances
#
@zhiguangwang
zhiguangwang / mono-certmgr.md
Last active September 7, 2018 17:42
Manage SSL Certificates for Mono with Certificate Manager.

Manage SSL Certificates for Mono with Certificate Manager

For more details, see certmgr.

Note for commands to work, certificate must be in DER format.

Valid certificate store names are:

  • Trust (ROOT CA)
  • CA (Intermediate CA)
@zhiguangwang
zhiguangwang / README.md
Last active March 21, 2019 17:53
Performance cost of passing std::function as parameter.

Environment

  • Intel i7-4790 @ 3.60GHz
  • Ubuntu 14.04.5 LTS (Windows Subsystem Linux)
  • GCC 6.2.0
  • Clang 3.9.1
  • CXXFLAGS -std=c++14 -O2

Output

@zhiguangwang
zhiguangwang / websocket-elb.md
Last active April 23, 2019 20:23
Configure websockets behind an AWS ELB.
@zhiguangwang
zhiguangwang / README.md
Last active May 5, 2019 10:01
bash curl loop
curl-loop() { while true; do echo "$(date +%Y-%m-%dT%H:%M:%S%z) $(curl --silent --show-error ${1})"; sleep ${2:-0.5}; done }

Usage

curl-loop <url> [interval]