Skip to content

Instantly share code, notes, and snippets.

View maxwu's full-sized avatar
🎠

Max WU maxwu

🎠
View GitHub Profile
@maxwu
maxwu / markdown-details-collapsible.md
Created May 2, 2020 05:13 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@maxwu
maxwu / git_push_empty_to_remote.sh
Created September 13, 2019 23:48
Commit an empty change and push it to remote git repo - for testing git webhook events
git commit --allow-empty -m "Robot-CM: $(date)" && git push
@maxwu
maxwu / git_br.sh
Created September 13, 2019 01:31
Return the Git Branch name on local repo
git branch 2>/dev/null | grep '^*' | colrm 1 2
@maxwu
maxwu / json-format-buffer.vim
Created September 4, 2019 23:02
Format JSON contents in current VIM buffer
%!python -m json.tool
@maxwu
maxwu / measure-time.ps
Created September 4, 2019 20:36
Measure the process running time in Powershell env
# Measure Powershell running time
Measure-Command { $PATH_TO_PS_FILE.ps $PARAMETERS | Out-Host }
@maxwu
maxwu / download and build git
Created August 29, 2019 10:19 — forked from avivey/download and build git
install git from source (For Ubuntu)
cd /tmp
wget -O git.zip https://github.com/git/git/archive/master.zip
unzip git.zip
cd git-*
sudo apt-get install make autoconf libcurl4-gnutls-dev gettext gcc zlib1g-dev
make configure
./configure --prefix=/usr --without-tcltk
make all
@maxwu
maxwu / rm_obs_img.sh
Last active August 20, 2019 12:06
Remove obsoleted docker images
#删除虚悬镜像
docker image prune --force
#删除停止或一直处于已创建状态的实例
docker ps --filter "status=exited"|sed -n -e '2,$p'|awk '{print $1}'|xargs docker rm
docker ps --filter "status=created"|sed -n -e '2,$p'|awk '{print $1}'|xargs docker rm
#删除REPOSITORY是长uuid的镜像
docker images | sed -n -e '2,$p'|awk '{if($1 ~ /[0-9a-f]{32}/) print $1":"$2}'|xargs docker rmi
@maxwu
maxwu / list_proc_c_sharp.cs
Last active November 2, 2017 06:17
C# List Processing
// Join two list to a dict.
var keys = new List<int> { 1, 2, 3 };
var values = new List<string> { "one", "two", "three" };
var dictionary = keys.Zip(values, (k, v) => new { Key = k, Value = v })
.ToDictionary(x => x.Key, x => x.Value);
var lines = dictionary.Select(kvp => kvp.Key + ": " + kvp.Value.ToString());
Console.WriteLine(String.Join(Environment.NewLine, lines));
// Filter Pattern with Lamda to List
@maxwu
maxwu / context_manager_in_java.md
Last active August 16, 2017 03:36
Context Manager in Java

The sample is implemented in Java to create a context manager as in Python. It provides open action by object constructor and offers automatically close through an AutoCloseable interface.

import org.openqa.selenium.WebDriver;
import java.util.Arrays;
import java.util.List;

public class FrameSwitcher implements AutoCloseable {
    private WebDriver driver;
    List<String> frameChain;
@maxwu
maxwu / RedirectStderrToFile.java
Created August 14, 2017 03:06
Redirect stderr printout to file in Java
try {
File file = new File("stderr.log");
FileOutputStream fos = null;
fos = new FileOutputStream(file);
PrintStream ps = new PrintStream(fos);
System.setErr(ps);
} catch (FileNotFoundException e) {
e.printStackTrace();
}