This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
top # list processes, shift+p to sort processes by CPU usage | |
top -H -p <pid> # list threads, shift+p to sort threads by CPU usages | |
printf "%x\n" <tid> # convert tid to hexadecimal, called nid | |
jstack -l <pid> | grep -i <nid> -A 15 # get stack trace of the thread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image_id="$1" | |
for i in $(docker images -q); do | |
docker history $i | grep -q "$image_id" && echo $i; | |
done | sort -u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go to file begin/end: | |
fn + cmd + <-/-> | |
file structure popup: | |
fn + cmd + F12 | |
search everywhere: | |
shift shift | |
search for classes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
set -euo pipefail | |
src_host="$1" | |
src_path="$2" | |
dst_host="$3" | |
dst_path="$4" | |
pattern="${5:-*}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install docker | |
yum check-update | |
curl -fsSL https://get.docker.com/ | sh | |
systemctl start docker | |
systemctl status docker | |
systemctl enable docker | |
systemctl status docker | |
# Set up the server-side of things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/ | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Indirect expansion | |
# aax="x" | |
# aay="y" | |
# var_name="aax" | |
# echo ${!var_name} | |
x | |
# var_name="aay" |