Skip to content

Instantly share code, notes, and snippets.

View jaygooby's full-sized avatar
✏️
working on https://writiny.com in my sparse spare time

Jay Caines-Gooby jaygooby

✏️
working on https://writiny.com in my sparse spare time
View GitHub Profile
@jaygooby
jaygooby / git_notes.md
Last active February 6, 2026 12:49
Git, you bloody git

Rename a remote

git remote rename <old-name> <new-name>

Case Insensitive search all commit messages

git log -i --grep='weavils'

Add --all if you also want to check all branches, not just the current one.

Alias for recently edited branches

git lb

@jaygooby
jaygooby / log4j-jndi.conf
Last active October 13, 2025 15:04
fail2ban filter rule for the log4j CVE-2021-44228 exploit
# log4j jndi exploit CVE-2021-44228 filter
# Save this file as /etc/fail2ban/filter.d/log4j-jndi.conf
# then copy and uncomment the [log4j-jndi] section
# to /etc/fail2ban/jail.local
#
# jay@gooby.org
# https://jay.gooby.org/2021/12/13/a-fail2ban-filter-for-the-log4j-cve-2021-44228
# https://gist.github.com/jaygooby/3502143639e09bb694e9c0f3c6203949
# Thanks to https://gist.github.com/kocour for a better regex
#
@jaygooby
jaygooby / netblock-from-whois
Last active April 21, 2025 11:06
Gets and caches the netblock owner from `whois` for an IP address
#!/bin/bash
#
#
# MIT License
#
# Copyright (c) 2022 Jay Caines-Gooby, @jaygooby, jay@gooby.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@jaygooby
jaygooby / monit-alert-slack.sh
Last active February 17, 2025 20:39
Pipe your Monit email alerts into Slack
#!/bin/bash
# Save this file as e.g. /usr/local/bin/monit-alert-slack.sh
# then chmod +x /usr/local/bin/monit-alert-slack.sh
#
# In your /etc/monitrc set a user to get the alerts you
# want pushed to Slack:
#
# set alert monit-alerts@localhost
#
# and then in /etc/aliases set this as the user which
@jaygooby
jaygooby / src-hilite-lesspipe.sh
Last active January 21, 2025 14:02
A modified version of gnu source-highlight's src-hilite-lesspipe.sh that also works with piped files and files with no extensions. It uses the file command to guess the language. This means you can use source-highlight in conjunction with commands like "git show"
#! /bin/bash
#
# Based on http://git.savannah.gnu.org/cgit/src-highlite.git/tree/src/src-hilite-lesspipe.sh.in
# by Lorenzo Bettini
#
# Modified by Jay Caines-Gooby to support piped files
# jay@gooby.org
# @jaygooby
#
# Typically called by setting:
@jaygooby
jaygooby / Dockerfile
Last active June 13, 2024 18:24
Testing my understanding of how `BUNDLE_DEPLOYMENT` affects `bundle install`
# syntax = docker/dockerfile:1
FROM registry.docker.com/library/ruby:3.3.1-slim as base
ARG BUNDLE_DEPLOYMENT \
BUNDLE_WITHOUT
ENV BUNDLE_DEPLOYMENT=$BUNDLE_DEPLOYMENT \
BUNDLE_WITHOUT=$BUNDLE_WITHOUT \
BUNDLE_PATH="/usr/local/bundle" \
@jaygooby
jaygooby / strip_related_videos.php
Created November 4, 2011 13:51
Always put a rel=0 attribute on Youtube embedded videos so that related videos aren't shown at the end

If you import live data into Google Docs spreadsheets using the importdata function and you want to force a refresh at a certain interval, but you also want to ensure that some cache-busting goes on, append a querystring that's the epoch time value that the refresh occurs, so for a sheet that should grab new data every hour you could force an update like this:

importData("http://example.com/data.csv?" & hour(googleclock()) & ")")

But the url requested looks like this: http://example.com/data.csv?11 if the refresh happened at 11am. The next day at 11, the url will be the same, so there's a chance you may get cached data. To get around this, use an epoch time-based refresh. The formula:

=((date(year(googleclock()),month(googleclock()),day(googleclock())) & " " & time(hour(googleclock()), 0, 0)) - DATE( 1970;1;1))*86400

gives you the epoch timestamp for the time at the current hour. If you wanted the timest

# DOH. There's a command for this already:
ssh-keygen -R <the host>
@jaygooby
jaygooby / bluetooth-device-toggle.applescript
Created August 8, 2023 10:47
Toggle your Nothing ear (1) as the active bluetooth device
# Totally stolen from
# https://gist.github.com/ieatfood/814b065964492f71f728da59a47413bc
#
# Export this applescript as an app, and then just double click to toggle on & off
use framework "IOBluetooth"
use scripting additions
set blueToothDevice to "Nothing ear (1)"