Skip to content

Instantly share code, notes, and snippets.

View sj26's full-sized avatar

Samuel Cochran sj26

View GitHub Profile
View aws_s3_uri.rb
require "uri"
# Parses an S3 URI for region, bucket and key
# Based on the java sdk:
# Reference:
sj26 / buildkite-automatic-sso.user.js
Last active October 19, 2023 00:18
I'm tired of clicking SSO buttons on
View buildkite-automatic-sso.user.js
// ==UserScript==
// @name buildkite-automatic-sso
// @description I'm tired of clicking SSO buttons on
// @match*
// @run-at document-idle
// ==/UserScript==
if (document.title.match(/^Authorization Required:/)) {
document.querySelector("input[type=submit][value^='Sign in to your'], input[type=submit][value^='Continue with']").click();
sj26 / slack-hide-install-alert.user.css
Last active August 25, 2023 00:21
Slack hide install alert user script
View slack-hide-install-alert.user.css
/* ==UserStyle==
@name slack-hide-install-alert
@description No, really, I don't want it.
==/UserStyle== */
.p-workspace_banner__desktop-download-app {
display: none !important;
View timcopter.txt
T __/ [] \
TIM===__ \
M \________]
sj26 / slack-archive-redirect.user.js
Created July 25, 2022 00:01
Open slack in the browser straight away — no more "open this link in your browser"
View slack-archive-redirect.user.js
// ==UserScript==
// @name slack-archive-redirect
// @namespace
// @version 1
// @description Open slack in the browser straight away
// @author
// @match https://**
// @grant none
// ==/UserScript==
sj26 / activerecord-lifetime.rb
Created March 3, 2022 01:38
ActiveRecord Connection Lifetime controls for using postgres with an autoscaling pgbouncer service safely
View activerecord-lifetime.rb
# frozen_string_literal: true
# Connection lifetime for ActiveRecord
# Make sure that connections to the database can only live for a certain number
# of seconds. Once lifetime is reached, the underlying connection will be
# reconnected. This is enforced when checking out a connection for use from the
# pool. Use in combination with idle_timeout to enforce connection lifetime on
# idle connections as well.
View trello-hide-workspace-nav.user.css
/* ==UserStyle==
@name trello-hide-workspace-nav
@description Hide new trello workspace nav when it is collapsed (press "[")
==/UserStyle== */
[data-test-id="workspace-navigation-collapsed-container"] {
display: none !important;
sj26 / rspec
Last active July 19, 2021 22:49
View rspec
set -euo pipefail
echo -e "--- :database: Preparing databases"
bin/rake db:test:prepare db:job_log_chunks:reset
echo -e "+++ :rspec: Running \033[33mspecs\033[0m :cow::bell:"
sj26 / basecamp-pull-to-refresh.user.js
Last active June 10, 2021 01:58
I use the heystack page as the root of my basecamp tab, and often want to read notifications then go back to the heystack with a trackpad swipe, but then the heystack contents is outdated because turblinks restores the previous contents. So this lets me stay on the trackpad and do a pull-to-refresh to update the notifications. Ideally it would r…
View basecamp-pull-to-refresh.user.js
// ==UserScript==
// @name basecamp-pull-to-refresh
// @description Pull to refresh the Basecamp 3 Heystack page.
// @author Samuel Cochran <>
// @license MIT
// @version 1
// @match*/my/readings
// @run-at document-end
// @homepage
// ==/UserScript==
sj26 / active_record_timescale_extensions.rb
Last active June 4, 2021 00:16
Timescale extensions for ActiveRecord
View active_record_timescale_extensions.rb
# Put this in config/initializers/
module ActiveRecord::Tasks::TimescaleExtensions
def structure_load(filename, extra_flags)
# If this structure is using timescaledb then we need to take some extra steps
if system "grep", "-Eq", "CREATE EXTENSION( IF NOT EXISTS)? timescaledb", filename
puts "Enabling timescale extension"