Skip to content

Instantly share code, notes, and snippets.


Brandon Keepers bkeepers

View GitHub Profile
bkeepers / flipper-bugsnag.rb
Last active Dec 16, 2022
Flipper + BugSnag feature flags
View flipper-bugsnag.rb
# config/initializers/flipper.rb
ActiveSupport::Notifications.subscribe('feature_operation.flipper') do |event|
operation, feature_name, result = event.payload.values_at(:operation, :feature_name, :result)
return unless operation == :enabled?
result ? Bugsnag.add_feature_flag(feature_name) : Bugsnag.clear_feature_flag(feature_name)
bkeepers / example.rb
Last active Sep 14, 2022
Multivariate - A/B - split testing with Flipper
View example.rb
# Register test groups
Flipper.register(:group_a) do |actor, context|
# Algorithm or database lookup to determine if a user is in this group
# e.g. 10% percentage of actors
crc32('group_a' + context.feature_name + actor.flipper_id) % 100 < 10
Flipper.register(:group_b) do |actor, context|
bkeepers /
Last active Oct 24, 2022
Fail Rails system tests if there are any JavaScript errors

We're on the cusp of 2022 and most software is now written in JavaScript, but it is still virtually impossible to fail integration tests on a JavaScript error and get a useful stack trace from the browser.

This gist includes my description of the problem and sample code from my attempts to solve it.

What I want:

  • Integration test should fail (preferabbly immediately) on any uncaught JavaScript error (window.onerror, unhandledrejection, etc)
  • The stack trace should use source maps and be close to what browsers show in DevTools

The tools I'm currently using:

bkeepers / iframe_location_controller.js
Last active Mar 12, 2021
Stimulus controller to save location of same-origin iframe in hash of parent window and restore on reload.
View iframe_location_controller.js
import { Controller } from 'stimulus'
// Stimulus controller to save location of same-origin iframe in hash of parent
// window and restore on reload.
// <iframe src="…"
// data-controller="iframe-location"
// data-action="load->iframe-location#save">
// </frame>
View data.csv
age length price
36 29 12500
41 38 34900
45 13 1250
11 26 22400
19 48 265000
33 38 89900
5 42 399000
39 28 3200
39 27 14750
bkeepers / application.rb
Created May 13, 2020
Add methods to `rails console`
View application.rb
module SailboatGuide
class Application < Rails::Application
console do
require 'console_helpers'
TOPLEVEL_BINDING.eval('self').extend ConsoleHelpers
bkeepers / delete-comment.js
Created Sep 14, 2017
Probot app to delete 👍 and single emoji comments.
View delete-comment.js
// :+1: comments and single emoji
const pattern = /^\W*(:[\w-\+]+:|[\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])\W*$/g;
module.exports = robot => {
robot.on('issue_comment.created', context => {
if(context.payload.comment.body.match(pattern)) {
bkeepers / .env
Last active Nov 2, 2020
Probot plugin that ensures every commit message has the word "bananas"
View .env
# The ID of your GitHub App
# Uncomment this to get verbose logging
# LOG_LEVEL=trace # or `info` to show less
# Go to set this to the URL that you are redirected to.
View serialPromise.js
// Turn any function calls on a promise into function calls on the result.
// For example:
// serialPromise(promise).foo();
// Is the same as calling:
// promise.then(result =>;
bkeepers /
Last active Jan 20, 2018
Tell me your story about how open source has impacted your career.

I’m working on a talk about the relationship between community participation and careers, and want to hear from people who feel like open source has impacted their career. Tell me your story!

Below are some questions related to get you started. Feel free to either fork this gist, blog your answers and send me the link, or email them directly to me at I will ask your permission before sharing anything about your story publicly.

  • How do you feel your participation in open source has impacted your career, both good and bad?

  • How did you first get exposed to open source? Why did you decide to learn more about it?

  • Do you code? If so, were you a coder when you got started with open source? Why did you learn to code?