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 | |
# 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 |
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 | |
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 |
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 | |
# 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 |
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 | |
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/ |
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
# [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 | |
... |
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 | |
} |
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
# 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
# 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
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/ |
OlderNewer