Skip to content

Instantly share code, notes, and snippets.

Matthew Adams matthewadams

Block or report user

Report or block matthewadams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@matthewadams
matthewadams / npm-update.sh
Created Dec 28, 2018
Update all npm packages to their latest versions
View npm-update.sh
#!/usr/bin/env bash
NPM_UPDATE_DEFAULT_PACKAGE_FILE=package.json
NPM_UPDATE_PACKAGE_FILE=$NPM_UPDATE_DEFAULT_PACKAGE_FILE
usage() {
cat<<EOF
Update outdated npm packages to the latest available
$(basename "$0")
@matthewadams
matthewadams / release-helm-chart.sh
Last active Aug 14, 2018
release-helm-chart.sh
View release-helm-chart.sh
#!/usr/bin/env bash
# This script implements the release branch workflow for helm charts.
#
# Requirements:
# git
# docker
# TODO: port this from bash to plain ol' sh (regex matching needs to be ported)
@matthewadams
matthewadams / release-docker-image-on-codefresh.sh
Created Aug 13, 2018
release-docker-image-on-codefresh.sh
View release-docker-image-on-codefresh.sh
#!/usr/bin/env bash
# This script implements the release branch workflow for docker images built by codefresh.io.
#
# Requirements:
# git
# docker
# TODO: port this from bash to plain ol' sh (regex matching needs to be ported)
@matthewadams
matthewadams / _helpers.tpl
Created Feb 3, 2018
.dockercfgjson Helm template
View _helpers.tpl
{{- define "dockercfg" -}}
{{- $hostname := required "A Docker image registry hostname is required" .Values.image.registry.auth.hostname -}}
{{- $username := required "A Docker image registry username is required" .Values.image.registry.auth.username -}}
{{- $password := required "A Docker image registry password is required" .Values.image.registry.auth.password -}}
{{- $email := required "A Docker image registry email is required" .Values.image.registry.auth.email -}}
{{- $auth := printf "%s:%s" $username $password | b64enc -}}
{{- $cfg := printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}}" $hostname $username $password $email $auth -}}
{{- $cfg | b64enc -}}
{{- end -}}
View bash-colorized-output-functions.sh
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[1;34m'
CLEAR='\033[0;0m'
red() {
printf "${RED}$1${CLEAR}\n"
}
green() {
@matthewadams
matthewadams / git-scrum.sh
Last active Jun 6, 2017
git log for scrum across multiple repos
View git-scrum.sh
#!/usr/bin/env bash
SCRUM_TIME=${SCRUM_TIME-"08:45:00"}
BEFORE_DAY=${BEFORE_DAY-$(date +%Y-%m-%d)}
BEFORE_TIME=${BEFORE_TIME-$SCRUM_TIME}
AFTER_DAY=${AFTER_DAY-$(python -c "from datetime import datetime, timedelta; before = datetime.strptime('$BEFORE_DAY','%Y-%m-%d').date(); monday = before.strftime('%u') == '1'; days = -3 if monday else -1; after = before + timedelta(days=days); print after;")}
AFTER_TIME=${AFTER_TIME-$BEFORE_TIME}
TZ_OFFSET=$(date +%z)
AFTER="${AFTER_DAY}T${AFTER_TIME}${TZ_OFFSET}"
BEFORE="${BEFORE_DAY}T${BEFORE_TIME}${TZ_OFFSET}"
DIR="${DIR-$PWD}"
@matthewadams
matthewadams / Spark aggregateByKey
Last active Mar 11, 2016 — forked from tmcgrath/Spark aggregateByKey
Spark aggregateByKey example
View Spark aggregateByKey
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.1.0
/_/
Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65)
Type in expressions to have them evaluated.
Type :help for more information.
@matthewadams
matthewadams / gist:6686329
Created Sep 24, 2013
compare sha1 on Mac OS X
View gist:6686329
hash=(`openssl sha1 $1`)
hash=${hash[1]}
if [ "$2" != "$hash" ]; then
echo "Mismatch: given $2, calculated $hash" > /dev/stderr
exit 1
else
echo "ok"
fi
@matthewadams
matthewadams / gist:6686305
Created Sep 24, 2013
echo sha1 to stdout on Mac OS X
View gist:6686305
hash=(`openssl sha1 $1`)
echo "${hash[1]}"
@matthewadams
matthewadams / gist:6516544
Created Sep 10, 2013
SOM Property Methods eclipse template
View gist:6516544
public ${Type} get${UpperName}() {
return ${lowerName};
}
public void set${UpperName}(${Type} ${lowerName}) {
testSet${UpperName}(${lowerName});
doSet${UpperName}(${lowerName});
}
protected void testSet${UpperName}(${Type} ${lowerName}) {
You can’t perform that action at this time.