Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
export LANG=C
#export CC=gcc
export CC=clang
export COMPILER_WARNINGS_FATAL=false
export ALLOW_DOWNLOADS=true
export HOTSPOT_BUILD_JOBS=8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export ALT_BOOTDIR=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export ALT_PARALLEL_COMPILE_JOBS=8
@zhangw
zhangw / compiling_building_c_cpp_notes.md
Created September 2, 2019 13:26 — forked from gubatron/compiling_building_c_cpp_notes.md
Things to remember when compiling and linking C/C++ programs

Things to remember when compiling/linking C/C++ software

by Angel Leon. March 17, 2015; August 29, 2019.

Include Paths

On the compilation phase, you will usually need to specify the different include paths so that the interfaces (.h, .hpp) which define structs, classes, constans, and functions can be found.

With gcc and llvm include paths are passed with -I/path/to/includes, you can pass as many -I as you need.

In Windows, cl.exe takes include paths with the following syntax: /I"c:\path\to\includes\ you can also pass as many as you need.

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@zhangw
zhangw / brew-mirrors.sh
Created July 10, 2019 06:03 — forked from hyperfact/brew-mirrors.sh
brew mirrors
## tsinghua
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
brew update
# brew bottles
@zhangw
zhangw / gist:d9b8b95c83931a2ce623ce7a596cb82d
Created June 13, 2019 07:16 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@zhangw
zhangw / config-git-proxy.txt
Created April 30, 2019 08:42 — forked from bynil/config-git-proxy.txt
Use git over socks5 proxy
Port: 1080
1. Create a file /YOUR PATH/gitproxy.sh with content:
#!/bin/sh
nc -X 5 -x 127.0.0.1:1080 "$@"
2. Edit your ~/.gitconfig
# For git://
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@zhangw
zhangw / aliyun_pub_ip.sh
Created April 4, 2018 02:55
show aliyun public ip
curl -fsL 100.100.100.200/latest/meta-data/eipv4
@zhangw
zhangw / Java8DateTimeExamples.java
Created January 2, 2018 06:21 — forked from mscharhag/Java8DateTimeExamples.java
Examples for using the Java 8 Date and Time API (JSR 310)
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import static java.time.temporal.TemporalAdjusters.*;
public class Java8DateTimeExamples {
@zhangw
zhangw / AmountAsStringi18n.java
Created December 28, 2017 12:57
字符串金额-i18n
private static String convertStringNumber(String stringNumber, Locale locale){
BigDecimal dec = new BigDecimal(stringNumber);
int scale = dec.scale();
String format;
switch (scale) {
case 0: format = ",##0"; break;
case 1: format = ",##0.0"; break;
case 2: format = ",##0.00"; break;
case 3: format = ",##0.000"; break;
case 4: format = ",##0.0000"; break;