Skip to content

Instantly share code, notes, and snippets.

View codyzu's full-sized avatar

Cody Zuschlag codyzu

View GitHub Profile
@codyzu
codyzu / updatemirrors
Created February 10, 2017 10:10
update arch mirrors using reflector
sudo reflector --verbose -l 200 -p http --sort rate --save /etc/pacman.d/mirrorlist
@codyzu
codyzu / time-over-http-hack
Created February 10, 2017 10:12
update time from google.com (useful when network blocks NTM)
date -s "$(wget -S "http://www.google.com/" 2>&1 | grep -E '^[[:space:]]*[dD]ate:' | sed 's/^[[:space:]]*[dD]ate:[[:space:]]*//' | head -1l | awk '{print $1, $3, $2, $5 ,"GMT", $4 }' | sed 's/,//')"
@codyzu
codyzu / pl
Created February 10, 2017 10:13
pygmentize piped to less
#!/bin/bash
pygmentize $1 | less -R -N
@codyzu
codyzu / .bashrc
Last active April 12, 2017 15:30
.bashrc for arch (antegros)
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# improve the path
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
@codyzu
codyzu / gcloud-publish-cron.sh
Last active February 7, 2018 16:18
gcloud-publish-cron
gcloud beta pubsub topics publish cron-5-minutes --message="run cron"
@codyzu
codyzu / deploy-cf.sh
Created March 16, 2018 15:51
gcloud-deploy-cf
gcloud beta functions deploy my-cloud-function --source=https://source.developers.google.com/projects/${PROJECT}/repos/${SOURCE_REPO}/fixed-aliases/${GIT_TAG}
@codyzu
codyzu / every-5-minutes.cron.yaml
Created February 27, 2018 16:53
Kubernetes CronJob publishing to a PubSub topic
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: every-5-minutes
spec:
schedule: "*/5 * * * *"
jobTemplate:
spec:
template:
spec:
// Create a private instance of lodash
// since we will modify the memoize cache config
const {memoize} = require('lodash').runInContext();
// Set the memoize cache to use WeakMap
memoize.Cache = WeakMap;
const getUserFromDatabase = memoize(async ctx => {
const {
req: {
headers: {Authorization: userCred},
},
} = ctx;
const user = await db.getUserByCredential(userCred);
return user;
});