Skip to content

Instantly share code, notes, and snippets.


Nathan Broadbent ndbroadbent

View GitHub Profile
ndbroadbent / freeze_for_2s.txt
Created Jun 6, 2020
Minimal examples that freeze VS Code with a regex search
View freeze_for_2s.txt
# VS Code freezes for 1-2 seconds with regex search "([^]+\n)+"
# foo foo foo foo
foo(foo).foo foo 'foo'
foo(foo).foo foo 'foo'
' .foo-foo-foo'
).foo).foo foo('foo foo')
foo(foo).foo foo 'foo foo'
ndbroadbent / system.rake
Created Jun 1, 2020
Check for Debian updates
View system.rake
namespace :system do
desc 'Check for security updates for Debian packages'
task check_security_updates: :environment do
return unless Rails.env.production?['CRONITOR_ID_CHECK_SECURITY_UPDATES']) do
stdout, stderr, status = Open3.capture3('apt-get update')
unless status.success?
raise "'apt-get update' failed! stdout:\n#{stdout}\nstderr:\n#{stderr}"
set -e
read -r -d '' SUBMISSION_DATA <<'JSON'
"data": {
ndbroadbent / bookmarkbar
Created May 20, 2020
this image was in my bookmarks bar
View bookmarkbar
ndbroadbent / oj_spec.rb
Last active May 15, 2020
RSpec test to ensure that the Oj gem is working in a Rails application
View oj_spec.rb
# 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:
RSpec.describe 'Oj gem' do
it 'uses OJ to parse and generate JSON' do
ndbroadbent / void_invoices.rb
Created Apr 25, 2020
Void any forgiven Stripe invoices
View void_invoices.rb
class VoidForgivenInvoicesService
LIMIT = 100
class << self
def log(str)
puts str
def void_forgiven_invoices!
invoices = []
ndbroadbent /
Last active Dec 8, 2019
Much faster bash implementation for rake parallel:prepare (for parallel_tests gem)
set -eo pipefail
if [ -z "$ACTION" ]; then
ndbroadbent / getTotps - show image in console.js
Last active Aug 29, 2020 — forked from nmurthy/getTotps.js
export authy totp codes, show QR codes in the console
View getTotps - show image in console.js
/* 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 / Dockerfile.erb
Last active Nov 16, 2019
Compile Dockerfile templates for dev + builds
View Dockerfile.erb
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"
View embed_data_request_example_source.html
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" media="all" href="/assets/bootstrap-4e3cebc9fbc5fb97aaa32ed51a086b63d9fef4e3ce46082c4ecd8fa5dc3ddc2d.css" />
<link rel="stylesheet" media="all" href="/assets/web_form-be7376ecee212758c2e2f9e8c0ddd9f280c703b32cc8bb0a7afe3da0139d8336.css" />
You can’t perform that action at this time.