Skip to content

Instantly share code, notes, and snippets.

View ndbroadbent's full-sized avatar

Nathan Broadbent ndbroadbent

View GitHub Profile
@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
@ndbroadbent
ndbroadbent / shrine_file_migration_service.rb
Created October 12, 2019 15:45
Shrine file migration Rake task
# frozen_string_literal: true
# Run this with: rake storage:migrate
class ShrineFileMigrationService
def self.migrate_files!(options = {})
dry_run = options[:dry_run]
verbose = options[:verbose]
unless Shrine.version.to_s == '2.19.3'
@ndbroadbent
ndbroadbent / ci_cache
Last active September 2, 2020 12:15
A powerful CI caching tool for Google Cloud Storage
#!/bin/bash
set -e
# CI Cache Script for Google Cloud Storage
# TIP: Set CI_CACHE_VERBOSE=true while testing the script
# to show a list of all files that are compressed/extracted.
# Note that you might see "tar: write error" if there are too many
# files in the verbose output.
@ndbroadbent
ndbroadbent / .bashrc
Last active June 16, 2019 19:46
Notification function for long-running commands
# ~/.bashrc
# Here's a nice alert sound you can use: https://www.dropbox.com/s/ctziqfuqt5q9fek/alert.mp3?dl=0
# Find some more here: https://notificationsounds.com/notification-sounds
alias alert="afplay ~/sounds/alert.mp3"
function n() {
local ALERT="Alert from Bash"
local EXIT_CODE=0
@ndbroadbent
ndbroadbent / puma_sanity_check.sh
Last active June 10, 2019 22:05
Puma sanity check, for CI / Docker builds
#!/bin/bash
set -e
# When running on a local machine, we need to kill the Spring loader.
if [ -f .env ]; then spring stop; fi
# Ensures that the Rails app can boot and pass a simple health check.
export RAILS_ENV=production
export PORT=4123
export DATABASE_URL=postgresql:does_not_exist
@ndbroadbent
ndbroadbent / puma_sanity_check.sh
Created June 10, 2019 21:57
Puma sanity check, for CI / Docker builds
#!/bin/bash
set -e
# When running on a local machine, we need to kill the Spring loader.
if [ -f .env ]; then spring stop; fi
# Ensures that the Rails app can boot and pass a simple health check.
# Also ensures that RubyEncoder is working for the enterprise image.
export RAILS_ENV=production