Skip to content

Instantly share code, notes, and snippets.

Nathan Broadbent ndbroadbent

Block or report user

Report or block ndbroadbent

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ndbroadbent
ndbroadbent / ci_cache
Last active Jul 7, 2019
A powerful CI caching tool for Google Cloud Storage
View ci_cache
#!/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 Jun 16, 2019
Notification function for long-running commands
View .bashrc
# ~/.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 Jun 10, 2019
Puma sanity check, for CI / Docker builds
View puma_sanity_check.sh
#!/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 Jun 10, 2019
Puma sanity check, for CI / Docker builds
View puma_sanity_check.sh
#!/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
@ndbroadbent
ndbroadbent / sidekiq_health_check_job.rb
Last active Jun 10, 2019
An RSpec test that ensure that the Sidekiq worker can actually boot without crashing, and runs a real test job from Redis
View sidekiq_health_check_job.rb
# frozen_string_literal: true
# spec/jobs/worker_health_check_job_spec.rb starts a Sidekiq worker process
# and checks stdout for some expected strings. This ensures that Sidekiq
# can boot without crashing, and run a real job from a Redis queue.
class SidekiqHealthCheckJob
include Sidekiq::Worker
def perform(string)
@ndbroadbent
ndbroadbent / sidekiq_sanity_check_v3.sh
Created Jun 10, 2019
sidekiq_sanity_check_v3 - Revert to using --daemon flag, and use a lightweight Ruby script to push the job to Redis
View sidekiq_sanity_check_v3.sh
#!/bin/bash
set -e
if [ -f .env ]; then spring stop; fi
# This script is run in the CI build. It requires a REDIS_URL variable,
# and runs a test job through the WorkerHealthCheckJob.
# I added this check after I accidentally pushed a change that caused the sidekiq
# workers to crash on boot. The jobs were well-tested, but the actual
# sidekiq config had an error inside a #configure_server block, so the code
# only crashed when I started an actual Sidekiq worker process.
@ndbroadbent
ndbroadbent / sidekiq_sanity_check_2.sh
Last active Jun 10, 2019
sidekiq_sanity_check_2.sh
View sidekiq_sanity_check_2.sh
#!/bin/bash
set -e
if [ -f .env ]; then spring stop; fi
# This script is run in the CI build. It requires a REDIS_URL variable,
# and runs a test job through the WorkerHealthCheckJob.
# I added this check after I accidentally pushed a change that caused the sidekiq
# workers to crash on boot. The jobs were well-tested, but the actual
# sidekiq config had an error inside a #configure_server block, so the code
# only crashed when I started an actual Sidekiq worker process.
@ndbroadbent
ndbroadbent / sidekiq_sanity_check.sh
Last active Jun 10, 2019
Sidekiq test that I run on CI
View sidekiq_sanity_check.sh
#!/bin/bash
set -e
# This script is run in the CI build. It requires a REDIS_URL variable,
# and runs a test job through the WorkerHealthCheckJob.
# I added this check after I accidentally pushed a change that caused the sidekiq
# workers to crash on boot. The jobs were well-tested, but the actual
# sidekiq config had an error inside a #configure_server block, so the code
# only crashed when I started an actual Sidekiq worker process.
@ndbroadbent
ndbroadbent / Dockerfile.ruby
Last active May 12, 2019
Ruby Dockerfile with checkinstall (but checkinstall just freezes)
View Dockerfile.ruby
FROM debian:stretch
RUN apt-get update \
&& apt-get install -y \
curl ca-certificates \
checkinstall unzip build-essential \
automake libtool libtool-bin pkg-config \
bison \
dpkg-dev \
gcc \
@ndbroadbent
ndbroadbent / action_dispatch_parameter_filter.rb
Created Apr 27, 2019
Monkey Patch for ActionDispatch::Http::ParameterFilter::CompiledFilter to support more complex filtering rules
View action_dispatch_parameter_filter.rb
# lib/action_dispatch_parameter_filter.rb
require 'action_dispatch/http/parameter_filter'
if Rails.version != '5.2.2.1'
raise "You've updated the Rails version. " \
"Please check #{__FILE__} and ensure that everything still works."
end
module ActionDispatch
You can’t perform that action at this time.