Skip to content

Instantly share code, notes, and snippets.

@SpainTrain
SpainTrain / datastore_mapper.py
Created September 18, 2020 05:51
Approach to migrations in Google Cloud Datastore
# From https://cloud.google.com/appengine/articles/deferred
import logging
from google.appengine.ext import deferred, ndb
from google.appengine.runtime import DeadlineExceededError
class Mapper(object):
# Subclasses should replace this with a model class (eg, model.Person).
KIND = None
@SpainTrain
SpainTrain / twilio-invoices.js
Created December 9, 2019 19:59
Download multiple twilio invoices from the browser devtools
// from https://blog.logrocket.com/programmatic-file-downloads-in-the-browser-9a5186298d5c/
function downloadBlob(blob, filename) {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = filename || 'download';
const clickHandler = function() {
setTimeout(() => {
URL.revokeObjectURL(url);
@SpainTrain
SpainTrain / config_model.py
Created June 12, 2017 17:19
Store Config for Google App Engine Python App in Datastore (https://12factor.net/config)
from os import environ
from google.appengine.ext import ndb
from google.appengine.ext.ndb import model
from pydash import snake_case
class Config(ndb.Model):
value = ndb.StringProperty()
value_previous = ndb.StringProperty()
@SpainTrain
SpainTrain / gk_pr.md
Created October 10, 2016 14:25
GK PR that incorrectly links GH issues
@SpainTrain
SpainTrain / git-worktree-branch.sh
Created September 22, 2016 17:50
Checkout a new branch in a git worktree
#!/bin/bash
GIT_REPO_NAME=$(basename `git rev-parse --show-toplevel`)
BRANCH_NAME=${1}
WORKTREES_DIR="${HOME}/worktrees"
mkdir -p ${WORKTREES_DIR}/${GIT_REPO_NAME}
git branch ${BRANCH_NAME}
git worktree add ${WORKTREES_DIR}/${GIT_REPO_NAME}/${BRANCH_NAME} ${BRANCH_NAME}
@SpainTrain
SpainTrain / git-worktree-pr.sh
Last active March 13, 2019 19:03
git checkout PR into git worktree
#!/bin/bash
GIT_REPO_NAME=$(basename `git rev-parse --show-toplevel`)
PR_NUM=${1}
WORKTREES_DIR="${HOME}/worktrees"
mkdir -p ${WORKTREES_DIR}/${GIT_REPO_NAME}
# requires `git fetch-pr` alias credit: https://gist.github.com/gnarf/5406589
# fetch-pr = "!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1; }; f"
git fetch-pr ${PR_NUM}
@SpainTrain
SpainTrain / status_diplay_notify_send.py
Created December 8, 2015 18:48
cmus notify-send script
#! /usr/bin/env python
#
# cmus_desktop_notify.py: display song cmus is playing using notify-send.
# Copyright (C) 2011 Travis Poppe <tlp@lickwid.net>
#
# Version 2011.06.24
# http://tlp.lickwid.net/cmus_desktop_notify.py
# Usage: Run script for instructions.
@SpainTrain
SpainTrain / do-release.sh
Created October 9, 2015 20:08
bash script to check for release directive and bump, tag, and publish to npm
#!/bin/bash
set -ex
git config --global user.email "ci@provider.com"
git config --global user.name "CI"
git config --global push.default simple
LAST_COMMIT_MSG="$(git log -1 --pretty=%B)"
SEMVER_BUMP_TYPE="$(echo ${LAST_COMMIT_MSG} | sed -n 's/^.*[rR]elease v+\([a-z]\+\).*$/\1/p')"
@SpainTrain
SpainTrain / circle.yml
Created September 21, 2015 17:26
CircleCI machine config for node-gyp with Node v4.X
machine:
node:
version: 4.1
pre:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install gcc-4.9 g++-4.9
post:
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
@SpainTrain
SpainTrain / .noserc
Last active September 9, 2020 15:25
Relevant config files for a python GAE app using CircleCI
[nosetests]
verbosity=3
with-coverage=1
cover-branches=1
cover-xml=1
cover-xml-file=./coverage.xml
cover-min-percentage=66
with-profile=1