Skip to content

Instantly share code, notes, and snippets.

View fedora23_broadcom_wl.sh
#/usr/bin/env bash
# Install some pacakages we'll need to compile the driver below.
dnf install gcc kernel-devel -y
# Create working dir for Broadcom driver files and patches.
mkdir hybrid_wl_f23
# Change to working dir.
cd hybrid_wl_f23
@ouyi
ouyi / multiplication_formulas.sh
Created Oct 22, 2017
Bash script to print out the Table of Multiplication Formulas for school kids
View multiplication_formulas.sh
#!/usr/bin/env bash
for i in {1..9}; do
for j in $(seq 1 $i); do
echo -n "$j x $i = $( printf '% 2s' $(( $i * $j ))) "
done
echo
done
@ouyi
ouyi / android_data_backup.sh
Last active Dec 3, 2017
Backup and restore android data from a Fedora Linux host
View android_data_backup.sh
#!/usr/bin/env bash
dnf install -y android-tools
# backup apps
adb backup -all -f adb-backup-2017-12-03-v9.adb
# backup photos
adb pull /sdcard/DCIM/Camera/ v9_sdcard_DCIM_Camera/
@ouyi
ouyi / IsStringEmpty.java
Created Dec 17, 2017
java 8 test whether a nullable String is empty or not
View IsStringEmpty.java
// java 8 test whether a nullable String is empty or not
if (Optional.ofNullable(s).orElse("").isEmpty()) {
// s is null or empty
}
@ouyi
ouyi / glassfish_commands.sh
Last active Dec 18, 2017
Glassfish commands
View glassfish_commands.sh
#!/usr/bin/env bash
# docker run -p 14848:4848 -p 18080:8080 -p 18181:8181 --name glassfish oracle/glassfish:5.0
##########GENERATED ADMIN PASSWORD: f621b788 ##########
# docker exec -u 0 -it glassfish bash
ADMIN_PASSWORD=123456
echo "AS_ADMIN_PASSWORD=${ADMIN_PASSWORD}" > /tmp/glassfishpwd
@ouyi
ouyi / git_commands.sh
Last active Dec 27, 2017
Frequently used Git commands
View git_commands.sh
# 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!!!):
View ansible_settings_for_vault_diff.txt
# [your_project]$ cat .gitattributes
prod/group_vars/vaulted* diff=ansible-vault-prod merge=binary
# [your_project]$ cat ~/.gitconfig
[diff "ansible-vault-prod"]
textconv = ansible-vault view --vault-password-file ~/vault_prod.txt
...
@ouyi
ouyi / emr_test_apps.sh
Last active Jan 24, 2018
Built-in test apps on EMR 5.x
View emr_test_apps.sh
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/
@ouyi
ouyi / java_thread_dump.sh
Created Jan 27, 2018
Thread dump in Java
View java_thread_dump.sh
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
@ouyi
ouyi / docker_child_images.sh
Created Feb 15, 2018
Find docker child images
View docker_child_images.sh
image_id="$1"
for i in $(docker images -q); do
docker history $i | grep -q "$image_id" && echo $i;
done | sort -u