Skip to content

Instantly share code, notes, and snippets.

🐉

Bo Jeanes bjeanes

🐉
Block or report user

Report or block bjeanes

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
View ulid-as-uuid.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@bjeanes
bjeanes / legal.css
Created Sep 11, 2018
Format legal text
View legal.css
View README.md

Install auditing on a per-table basis, e.g.:

SELECT audit.audit_table('billing.subscriptions'),
       audit.audit_table('billing.customers'),
       audit.audit_table('billing.plans');
@bjeanes
bjeanes / oauth_stub_provider.rb
Last active Feb 28, 2018
Just a set of POROs for emulating a simple OAuth2 provider
View oauth_stub_provider.rb
require 'securerandom'
module Oauth
class StubProvider
AUTHORIZATION_TTL = 60.seconds
ACCESS_TTL = 1.hour
def initialize(authorization_ttl: AUTHORIZATION_TTL, access_ttl: ACCESS_TTL, **meta)
@authorization_ttl = authorization_ttl
@access_ttl = access_ttl
View genesis_public_key
049c18da630bd3e171c38668e12933e361eea5701ace20d78b86b4725126ba3f3e89d78d5528576ea216619c3cdfc74bf5e24aae70a16a693e2be5714e862811a9
View explicit_return.rb
def explicit
return 42
rescue
:rescued
else
:else
end
def implicit
42
View hash_intersection.rb
class Hash
# Returns a nested intersection of two Hashes.
#
# This draws a parallel to &/intersect on Array and Set.
#
# FIXME: However, those methods are not recursive, so it may make more sense
# to give this another name.
#
# Examples:
#
View README.md

Postgres does not really fully support unicode the way some users might expect. Unicode (much to some people's chagrin) supports multiple ways of encoding complex characters.

For instance, the character could be:

  • ば (\u306f\u3099)
  • ば (\u3070)

Like-wise, and á are different (\u0061\u0301 and \u00e1).

@bjeanes
bjeanes / no_new_nulls_trigger.sql
Last active Apr 10, 2017
Trigger to prevent introducing new NULL values to a list of specified columns. I'm using this because I have an 8mil-row, 100GB (with indexes) table that I can't afford to lock to add a NOT NULL constraint. This allows me to start enforcing data now, and back-fill the values without downtime. Later, when I can schedule downtime, another constrai…
View no_new_nulls_trigger.sql
/*
* Prevent INSERTs or UPDATEs that introduce NULLs. Useful for when the
* table is too big to add NOT NULL constraints without downtime that
* can't currently be performed.
*
* Use like:
*
* CREATE TRIGGER <name>
* AFTER INSERT OR UPDATE
* ON <table>
View capybara_chrome_workaround.rb
# Chromedriver has this annoying bug where when trying to click a button or
# something which is obscured by another element due to scrolling, it fails to
# click the button or link.
#
# This is a workaround to always scroll the element into view after finding it.
module Capybara
module Chrome
module Finders
def find(*args)
super(*args).tap do |node|
You can’t perform that action at this time.