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 / notify-cli
Created August 18, 2026 12:15
A simple macOS cli for a dismissible notification
#!/bin/bash
#
# Usage:
# ./notify
# ./notify "Hi"
# ./notify "Finished" "Your thing is done"
set -e
TITLE="${1:-Yo!}"
MESSAGE="${2:-Your thing completed}"
@jaygooby
jaygooby / src-hilite-lesspipe.sh
Last active August 7, 2026 09:21
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:
# DOH. There's a command for this already:
ssh-keygen -R <the host>
@jaygooby
jaygooby / git_notes.md
Last active June 1, 2026 16:11
Git, you bloody git

Checkout a stash overwriting the current branch

git checkout stash@{0} -- .

This will potentially overwrite uncommitted files so you may lose work.

Via https://www.vincentschmalbach.com/applying-git-stash-changes-with-force/

Create a git alias to show all your git aliases

git config --global alias.alias "! git config --get-regexp ^alias. | sed -e s/^alias.// -e s/\ /\ =\ /"

@jaygooby
jaygooby / log4j-jndi.conf
Last active April 14, 2026 18:35
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 / 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
@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 / 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" \

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