Skip to content

Instantly share code, notes, and snippets.

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.List;
public class PrintJvmOptions {
public static void main(String[] args) {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
List<String> options = runtimeMxBean.getInputArguments();
for(String o : options) {
System.out.println(o);
@ouyi
ouyi / intellij_mac_german_keyboard_shotcuts.txt
Last active March 11, 2018 15:42
Intellij MacOS German keyboard shortcuts
go to file begin/end:
fn + cmd + <-/->
file structure popup:
fn + cmd + F12
search everywhere:
shift shift
search for classes:
@ouyi
ouyi / jdk_keystore.sh
Created April 11, 2018 16:20
Commands for working with Java keystore
$ sudo keytool -storepass changeit -import -file /tmp/root.crt -noprompt -alias my-trusted-ca -keystore /Library/Java//JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/security/cacerts
Password:
Certificate was added to keystore
// changeit is the Java default keystore password
$ keytool -storepass changeit -list -keystore /Library/Java//JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/security/cacerts | grep my-trusted-ca
my-trusted-ca, Apr 11, 2018, trustedCertEntry,
@ouyi
ouyi / s2s_copy.sh
Last active July 18, 2018 15:52
Server-to-server file copying
#/usr/bin/env bash
set -euo pipefail
src_host="$1"
src_path="$2"
dst_host="$3"
dst_path="$4"
pattern="${5:-*}"
@ouyi
ouyi / sed_commands.sh
Last active July 22, 2018 22:05
Frequently used sed commands
# Remove trailing whitespaces using sed
sed -i 's/[ \t]*$//' input_file
# Append line after pattern matching
sed -i "/mypattern.*/a 'my new stuff'" input_file
# Print the 2nd line
sed -n '2p' input_file
# Remove the last line
@ouyi
ouyi / jinja2_file_less.py
Created September 7, 2018 08:20 — forked from wrunk/jinja2_file_less.py
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@ouyi
ouyi / daterange.py
Last active October 4, 2018 18:33
A command-line tool to work with dates
#/usr/bin/env python
import sys, argparse, pytz
from datetime import datetime, timedelta
DEFAULT_DATETIME_FORMAT = '%Y%m%d'
SECONDS_IN_A_DAY = 3600 * 24
def main():
parser = argparse.ArgumentParser(description='A command-line tool to work with dates')
@ouyi
ouyi / bash_parameter_expansion.txt
Last active October 20, 2018 20:56
Bash parameter expansion
## Indirect expansion
# aax="x"
# aay="y"
# var_name="aax"
# echo ${!var_name}
x
# var_name="aay"
@ouyi
ouyi / copy_reinvented.sh
Last active November 29, 2018 22:10
Bash boilerplate code for parsing command-line args
#/usr/bin/env bash
#set -euo pipefail
EXIT_SUCCESS=0
EXIT_FAILURE=1
IFS='' read -r -d '' USAGE <<HEREDOC
Copy-reinvented to showcase Bash heredoc usage and command-line arguments handling.
@ouyi
ouyi / minikube-sierra.md
Created December 4, 2018 21:41 — forked from inadarei/minikube-sierra.md
Minikube Setup: Docker for Mac / Sierra

Prerequisite: latest Docker for Mac on MacOS Sierra

$ brew update
$ brew install --HEAD xhyve
$ brew install docker-machine-driver-xhyve
$ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
$ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-darwin-amd64 &amp;&amp; chmod +x minikube &amp;&amp; sudo mv minikube /usr/local/bin/