Skip to content

Instantly share code, notes, and snippets.

View rickosborne's full-sized avatar

Rick Osborne rickosborne

View GitHub Profile
@rickosborne
rickosborne / concat-reg-exp.test.ts
Created January 7, 2025 23:25
Concatenate regular expressions
import { expect } from "chai";
import { describe, it } from "mocha";
import { concatRegExp } from "../concat-reg-exp.js";
describe(concatRegExp.name, () => {
it("works for simple cases", () => {
expect(concatRegExp(/foo/, /bar/)).eql(/foobar/);
expect(concatRegExp(/^foo$/, /^bar$/)).eql(/^foobar$/);
expect(concatRegExp(/foo/, /^bar$/)).eql(/foobar$/);
expect(concatRegExp(/^foo$/, /bar/)).eql(/^foobar/);
@rickosborne
rickosborne / infinity-pride.svg
Created August 22, 2023 21:03
Infinity Pride
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rickosborne
rickosborne / mastodon-thread-to-json.js
Last active April 23, 2023 23:45
Bookmarklet to extract a Mastodon thread into JSON
javascript:(function () {
/* ========================================
Mastodon thread scraper, by Rick Osborne.
Copy this entire file, from the opening "javascript:" to the last "();".
Create a new bookmark in your browser, using the copied text as the URL.
When you are on a Mastodon thread page, activate this bookmark.
======================================== */
function findOne(parent, selector, block) {
if (parent == null) {
return undefined;
@rickosborne
rickosborne / a2cw.js
Last active December 18, 2022 23:24
Apache2 status to CloudWatch metrics shovel/export script
/*
-----------------------------------------------------------
The world's simplest Apache2-to-CloudWatch metrics shovel,
by Rick Osborne (rickosborne.org, github:rickosborne)
LICENSE: CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0
https://creativecommons.org/licenses/by-nc-sa/4.0/
@rickosborne
rickosborne / gif-from-video.sh
Created November 26, 2022 18:23
Convert a video to a GIF
#!/bin/sh
# Because I can never rememeber the magic incantations.
# Note that FFMPEG won't do as good a job as GIF Brewery or other apps, but it's good enough in a pinch.
IN_FILE="$1"
OUT_FILE="${IN_FILE%.*}.gif"
PALETTE_FILE="${IN_FILE%.*}-palette.png"
if [[ "" == "${SEEK_SECS}" ]] ; then
SEEK_SECS="0"
@rickosborne
rickosborne / resume.json
Last active September 16, 2022 21:58
Rick Osborne's resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"email": "[email protected]",
"image": "https://rickosborne.org/images/rick-teach-hands.jpg",
"label": "Cloud & Mobile Engineering Force Multiplier",
"location": {
"countryCode": "US",
"region": "California"
},
@rickosborne
rickosborne / gloomhaven-family-rules.md
Last active December 15, 2018 21:08
Gloomhaven Family Rules

Gloomhaven Family Rules

The official rules for Gloomhaven are great for people who enjoy formalized systems and min-maxing, notsomuch for kids. These Family Rules include guidelines for streamlining play, rebalancing narrative and interaction over micromanagement.

These rules are not in any way official nor endorsed by anyone associated with Gloomhaven.

A more print-friendly version of this document is maintained in this Google Doc.

Table of Contents

function rain(heights) {
var maxHeight = Math.max.apply(Math, heights), rightSide = heights.length - 1;
var left, right, newLeft, newRight;
for (left = 0; heights[left] < maxHeight; left++);
for (right = rightSide; heights[right] < maxHeight; right--);
var pooled = 0;
for (var height = maxHeight; height > 0; height--) {
for (newLeft = left - 1; newLeft >= 0; newLeft--) {
if (heights[newLeft] == height) {
left = newLeft;
@rickosborne
rickosborne / catch-up-branches
Last active December 22, 2015 07:59
Rebase a bunch of branches in a safe(r) way.
#!/bin/bash
# Attempt to do the equivalent of:
# massrebase = "!sh -c 'for branch in $@; do git rebase $0 $branch; done;'"
if [[ -z "${SOURCE_BRANCH}" ]] ; then
SOURCE_BRANCH='origin/master'
fi
# Import some helper functions
@rickosborne
rickosborne / java-downgrade
Created August 12, 2013 18:10
The semi-officially-sanctioned instructions from Apple on how to revert to Java 6.
#!/bin/sh
sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws