Skip to content

Instantly share code, notes, and snippets.

View ndbroadbent's full-sized avatar

Nathan Broadbent ndbroadbent

View GitHub Profile
#!/bin/bash
set -e
TEMPLATE_ID="tpl_q56GMFtgY6JEEfzASd"
API_TOKEN_ID="api_test_7tKsjEfES39ENnNThX"
API_TOKEN_SECRET="EvpFND320XPPffPHz2OSrGISg2x1Ms0zjoX8FPfPgng"
read -r -d '' SUBMISSION_DATA <<'JSON'
{
"data": {
@ndbroadbent
ndbroadbent / bookmarkbar
Created May 20, 2020 13:22
this image was in my bookmarks bar
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASgAAAFOCAYAAAA1qoBeAAAAAXNSR0IArs4c6QAADDJJREFUeAHt3c+PZEUdAPCqtw0bQWYPHICoyapHhZUTHJZkD5oYD3Lai1zFXaNXNST+A3I1MboJN057g5s/iG7ACKcFyeIJWKMkaMKBLB6Gme6y3mT6x0y/nul5093zfnxeUul69arqVX1q8p3unurpGBwECBDYgMDNq+ncB7c+3h3fKoY4/MV/Hx2Mz6sei6pCZQQIEGiCgADVhFUwBgIEKgUEqEoWhQQINEFAgGrCKhgDAQKVAgJUJYtCAgSaICBANWEVjIEAgUqBWFmqkAABAjUFXnzk49+OUvrGguaXZ8pTzv915vxAdlDcf+3IPQgHajshQIDAEgI56lzK1Z5eomr5BGk2YB1oMkw7W17iHSBxQoBAkwQEqCathrEQIHBAwEu8AxxOCBA4rUCR4rXhoNia6yeFIgyHt8blMRTDNIhXxudzjw/FO94kn1NRQIDAOgR8Fm8dqvokQODMBLwHdWb0bkyAwHECAtRxQq4TIHBmAgLUmdG7MQECxwkIUMcJuU6AwJkJ2GZwZvRuTKBfAldvhtGvHo0vjGedYhqN8x4JECBAgAABAgQIECBAgAABAgQIECBAgACBQwLHfhYv3Uzndj75/fS7rGIY3nf9u/76dwjSKQECqxewD2r1pnokQGBFAgLUiiB1Q4DA6gUEqNWb6pEAgRUJCFArgtQNAQKrFxCgVm+qRwIEViQgQK0IUjcECKxeYG+bQbrxh2/tjka/XtR9StOvhokxHP1dVmFwLV7/9nuL+lJOgACBZQX29jPlTU4XZoPQUY1zvTKoLfwuq51Bmv9n6Ud16BoBAgQWCNhwuQBG8WoEUkrfyT19P6ev7/f4fn58Ncb4x/1zDwQWCghQC2lcOI1ADkyP5Pa/y+nZin5+mq+/ksuv5UD1n4rrigjsCewFqMEDW7d3/3fvmUqTVBQp7dwaX8
@ndbroadbent
ndbroadbent / oj_spec.rb
Last active May 15, 2020 13:39
RSpec test to ensure that the Oj gem is working in a Rails application
# frozen_string_literal: true
require 'rails_helper'
# This test makes sure that Oj is used to parse and generate all JSON.
# Your application needs to call: Oj.optimize_rails
# See: https://github.com/ohler55/oj/blob/develop/pages/Rails.md#notes
RSpec.describe 'Oj gem' do
it 'uses OJ to parse and generate JSON' do
@ndbroadbent
ndbroadbent / void_invoices.rb
Created April 25, 2020 20:17
Void any forgiven Stripe invoices
class VoidForgivenInvoicesService
LIMIT = 100
class << self
def log(str)
puts str
end
def void_forgiven_invoices!
invoices = []
@ndbroadbent
ndbroadbent / parallel_db_setup.sh
Last active December 8, 2019 05:33
Much faster bash implementation for rake parallel:prepare (for parallel_tests gem)
#!/bin/bash
set -eo pipefail
DATABASE_NAME="$1"
if [ -z "$PARALLEL_TEST_PROCESSORS" ]; then
PARALLEL_TEST_PROCESSORS="$2"
fi
ACTION="$3"
if [ -z "$ACTION" ]; then
ACTION="create"
@ndbroadbent
ndbroadbent / getTotps - show image in console.js
Last active July 23, 2021 14:02 — forked from nmurthy/getTotps.js
export authy totp codes, show QR codes in the console
/* base32 */
/*
Copyright (c) 2011, Chris Umbel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ndbroadbent
ndbroadbent / Dockerfile.erb
Last active November 16, 2019 09:45
Compile Dockerfile templates for dev + builds
FROM debian:stretch-slim
# Set up a node group + user, minimal .bashrc, .gemrc, install packages
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node \
&& echo 'export LS_OPTIONS="--color=auto"\
\nalias ls="ls $LS_OPTIONS"\
\nalias ll="ls $LS_OPTIONS -l"\
\nalias l="ls $LS_OPTIONS -lA"' >> "$HOME/.bashrc" \
&& echo "gem: --no-rdoc --no-ri" > "$HOME/.gemrc"
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
sample-coi.pdf
- FormAPI.io</title>
<link rel="stylesheet" media="all" href="/assets/bootstrap-4e3cebc9fbc5fb97aaa32ed51a086b63d9fef4e3ce46082c4ecd8fa5dc3ddc2d.css" />
<link rel="stylesheet" media="all" href="/assets/web_form-be7376ecee212758c2e2f9e8c0ddd9f280c703b32cc8bb0a7afe3da0139d8336.css" />
@ndbroadbent
ndbroadbent / skopeo-docker-merge-poc.sh
Created November 2, 2019 11:14
Proof-of-concept for merging the layers from multiple Docker images into a single Docker image
#!/bin/bash
# Proof of concept:
# * Build two Docker images
# * Deconstruct them into a directory with skopeo
# * Merge the layers together, and update digests in manifest/config
# * Reconstruct a merged Docker image with skopeo
# * Show the Docker history of the reconstructed image, and show that
# files from both images can be accessed in the merged image.
@ndbroadbent
ndbroadbent / Gemfile
Last active December 11, 2021 22:31
How to get accurate SimpleCov coverage with Spring in a Rails application
group :development, :test do
gem 'spring-commands-rspec', require: false
gem 'spring-watcher-listen', require: false
gem 'spring', require: false
# ...
end