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
((Get-Content $FilePath) -join "`r`n") + "`r`n" | Set-Content -NoNewline $FilePath |
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 | |
# pre-commit hook to prevent a commit if the commit includes changes that | |
# match a set of stop strings | |
FORBIDDEN='DO NOT COMMIT' | |
git diff --cached | grep -q -E "${FORBIDDEN}" | |
ret=$? | |
if [[ $ret = 0 ]]; then |
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
apply plugin:'groovy' | |
repositories { | |
mavenCentral() | |
} | |
dependencies{ | |
implementation 'org.codehaus.groovy:groovy:3.0.4' | |
implementation 'net.sourceforge.plantuml:plantuml:8059' | |
} |
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
length=40 | |
forbiddenChars="+*/^" | |
openssl rand 4096 | \ | |
LC_ALL=C tr -cd '[:alnum:][:punct:]' | \ | |
tr -d "${forbiddenChars}" | \ | |
fold -w "${length}" | \ | |
head -n 1 |
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 to ~/bin if it's already on the path; otherwise install to /usr/local/bin | |
case ":$PATH:" in | |
*":$HOME/bin/:"*|*":$HOME/bin:"*) | |
INSTALL_DIR="$HOME/bin" | |
;; | |
*) | |
INSTALL_DIR=/usr/local/bin | |
;; | |
esac |
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
# Mac OS ships with Bash 3.2, which lacks the read -a option, which makes reading into an array easy | |
# So this is a replacement | |
lines="first line | |
second line | |
third line" | |
linesArray=() | |
while read -r line; do | |
linesArray+=("$line") | |
done <<< "${lines}" |
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
logFile=~/log | |
# close stdout and stderr and redirect them to the log file | |
rm -f "${logFile}" | |
exec 1<&- | |
exec 2<&- | |
exec 1<>"${logFile}" | |
exec 2>&1 |
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
public java.lang.String toString() { | |
#if ( $members.size() > 0 ) | |
#set ( $i = 0 ) | |
return "{\"_class\":\"$classname\", " + | |
#foreach( $member in $members ) | |
#set ( $i = $i + 1 ) | |
#if ( $i == $members.size() ) | |
#set ( $postfix = "+" ) | |
#else | |
#set ( $postfix = "+ "", "" + " ) |
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
docker run -e POSTGRES_PASSWORD=password -p 5432:5432 postgres | |
# then connect to localhost:5432, database postgres, user postgres, password pasword |
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
# Try hard to make idempotent calls to services that are a little flaky | |
function retryableCurl() { | |
for i in `seq 1 5`; do | |
code="$(curl -s -o /dev/null -w "%{http_code}" "$@")" | |
if [[ $? -eq 0 && code -lt 300 && code -ge 200 ]]; then | |
return | |
fi | |
done | |
printf "Failed to curl with arguments $*\n" | |
} |
NewerOlder