Skip to content

Instantly share code, notes, and snippets.

View bjeanes's full-sized avatar
🕊️

Bo Jeanes bjeanes

🕊️
View GitHub Profile
# frozen_string_literal: true
require 'rodauth'
# Rodauth calls `clear_session` every time it updates the session. This includes when logging in. Unfortunately, this
# means that logging in as an admin will log you out as a user, and vice versa.
#
# This feature introduces a notion of a "scoped" session (inside Rodauth only) that has the following behaviours:
#
# * Adding a key to the session adds it as a sub-hash, scoped by the configuration name.
@bjeanes
bjeanes / gl2gt.rb
Last active October 26, 2020 22:38
scrappy script to migrate Gitlab->Gitea
#!/usr/bin/env ruby
## NOTE: sometimes (probably because GL can't handle load) the repo is created but the import/migrate fails.
## go to <gitea>/admin/repos?sort=size to find 0-byte repos, delete them, and try again. Unfortunately,
## deleting these repos (either because of that page or because the repo isn't fully initialised) doesn't
## clean up on disk, so I had to manually `rm -rf` them too.
require 'json'
require 'uri'
require 'net/https'
@bjeanes
bjeanes / AAA_uuid_generate_v6mc.sql
Last active July 22, 2022 00:27
Postgres UUIDv6 (non-standard)
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- My port of https://github.com/kurttheviking/uuid-with-v6-js
-- A hacky translation of:
-- - http://gh.peabody.io/uuidv6/
-- - https://tools.ietf.org/html/draft-peabody-dispatch-new-uuid-format
CREATE OR REPLACE FUNCTION uuid_v1_to_v6(v1 uuid)
RETURNS uuid AS $$
DECLARE
v6 text;
@bjeanes
bjeanes / settings.json
Created June 2, 2020 05:37
Windows Terminal Settings
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"copyOnSelect": true,
"profiles": {
"defaults": {
"closeOnExit": true,
"cursorShape": "bar",
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 September 11, 2018 00:36
Format legal text

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 February 28, 2018 09:13
Just a set of POROs for emulating a simple OAuth2 provider
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
049c18da630bd3e171c38668e12933e361eea5701ace20d78b86b4725126ba3f3e89d78d5528576ea216619c3cdfc74bf5e24aae70a16a693e2be5714e862811a9