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
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
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
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
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
cat >> input.txt | |
hello | |
world | |
world | |
<ctrl+D> | |
wget https://raw.githubusercontent.com/ouyi/tez-demo/master/src/test/resources/input.txt | |
hadoop fs -copyFromLocal input.txt /tmp/ |
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
# 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 |
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
# Update commit comments before the push | |
git commit -m "Fix an issue" | |
git commit -m "Fix an important issue" --amend | |
# Throw away all changes on local master and to have it exactly the same as origin/master: | |
git checkout master | |
git reset --hard origin/master | |
# Force origin/master to be the same as local master (dangerous!!!): |
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
# --- Join strings --- | |
function join_by { local IFS="$1"; shift; echo "$*"; } | |
# join_by ',' foo bar baz | |
# https://serverfault.com/questions/311856/portable-unix-way-to-join-strings-with-separator | |
echo -e "a\nb\nc" | tr '\n' ',' | sed 's/,$//g' # a,b,c | |
# --- Misc --- | |
# Retrieve the directory where the current script is in |
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
// java 8 test whether a nullable String is empty or not | |
if (Optional.ofNullable(s).orElse("").isEmpty()) { | |
// s is null or empty | |
} |