Skip to content

Instantly share code, notes, and snippets.

spmason / dependabump
Created December 15, 2021 10:45
Create an octopus-merge of all pending dependabot PRs that are passing CI
View dependabump
#!/usr/bin/env bash
git co -b dependabot-$(date '+%Y-%m-%d') && \
gh pr list --label dependencies --json number,headRefName --search 'status:success' --jq '.[].headRefName | "origin/\(.)"' \
| xargs git merge && \
spmason / pr
Last active July 15, 2022 10:54
GitHub "open PR" script. Add somewhere in your path, then opening a PR is as easy as typing `pr` on the branch you want to open a PR for
View pr
#!/usr/bin/env bash
# GitHub "Open Pull Request" script
# Add somewhere in your path, then opening a PR is as easy as typing `pr` while you're
# on the branch you want to open a Pull Request for
# - Uses the `hub` tool:
# - Assumes that the upstream repository is called 'origin' and your fork is named after your github username
spmason / kube
Created December 15, 2021 10:42
Command for working with k8s contexts without needing to use kubectx or similar
View kube
set -ue -o pipefail
if ! [ -f $CLUSTER_KUBECONFIG ]; then
echo "current-context: ${CLUSTER}" > $CLUSTER_KUBECONFIG
spmason / logging.js
Created January 24, 2012 13:35
A simple node module that makes console.log/error/warn/debug statements log through winston (simply include at the beginning of your app)
View logging.js
'use strict';
var util = require('util'),
winston = require('winston'),
logger = new winston.Logger(),
production = (process.env.NODE_ENV || '').toLowerCase() === 'production';
module.exports = {
middleware: function(req, res, next){, req.url, res.statusCode);
spmason /
Last active May 3, 2019 10:58
withGCloudCredentials Jenkins pipeline library plugin

This code is a Jenkins Shared Library plugin that allows you to run a command with specific gcloud credentials stored in Jenkins by the google-oauth-plugin

Note: You must have the "Google Cloud SDK" plugin installed, and a custom tool called gcloud setup for the activation to work (though this should work without that if you have another way of getting gcloud onto your slave machine)


withGCloudCredentials(<projectName>, <credentialsId>) {
  sh "gcloud <command>"
  sh "gsutil <command>"
spmason / mustache.js
Created April 11, 2012 13:35
RequireJS Module for loading Mustache templates
View mustache.js
* RequireJS mustache plugin
* usage:
* require(['ModuleA', 'mustache!myTemplate'], function (ModuleA, myTemplate) {
* var a = new ModuleA();
* var html = myTemplate({foo: 'bar'});
* $(a.el).html(html);
* });

Keybase proof

I hereby claim:

  • I am spmason on github.
  • I am spmason ( on keybase.
  • I have a public key ASAceBYevAn4wzt1xOUf4yh78gRqksgRkZl5ZdGwl1Qgugo

To claim this, I am signing this object:

spmason / gist:7889481
Created December 10, 2013 11:55
Checkout PRs. I'm not sure where I got this from but I can't take credit for it
View gist:7889481
# Checks out a PR to a pr/<number> local branch
# Usage: git pr <number> [<upstream>]
git config --global '!git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1 && :'
# Deletes pr/<number> branches
# Usage: git pr-clean
git config --global '!git for-each-ref refs/heads/pr/* --format='"'"'%(refname)'"'"' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'