Skip to content

Instantly share code, notes, and snippets.

View cmbuckley's full-sized avatar

Chris Buckley cmbuckley

View GitHub Profile
@cmbuckley
cmbuckley / lockdown.json
Last active October 22, 2020 14:16
Match postcode to COVID lockdown key points
{
"E92000001": {
"country_or_area": "England",
"council": 0,
"wards": 0,
"postcodes": 0,
"full_or_partial": "F",
"key_points": "Your area is under Covid restrictions, in the Tier 1 (medium alert) category for England.",
"meeting_friends_and_family": "* You can mix socially in a group of up to six people from multiple households. This includes children and applies indoors and outdoors, including private homes. \n* Socialising in larger groups is against the law, with fines up to £6,400.\n* There are exceptions, for example if your household or support bubble is larger than six, or if someone enters your house to carry out work, registered childcare or care for a vulnerable person.\n",
@cmbuckley
cmbuckley / test-old-usertrust.sh
Last active May 31, 2020 18:16
Check for old USERTrust intermediate certificate
#!/bin/bash
# Checks a server certificate chain for old USERTrust intermediate cert,
# which will expire in May 2020.
#
# Possible output:
#
# • Error (e.g. cannot connect to host)
# • Not a Sectigo/Comodo chain (cannot find one of the CAs)
# • New USERTrust root cert found (valid, but superfluous)
@cmbuckley
cmbuckley / update-ufw-github.sh
Created January 20, 2020 12:32
Update UFW with IPs from GitHub
#!/bin/bash
github=$(curl -s https://api.github.com/meta | jq -r '.web | .[]' | sed 's~/32~~' | sort)
ufw=$(ufw status | grep '# GitHub' | awk '{print $1}' | sort)
comm -13 <(echo "$ufw") <(echo "$github") | while read addition; do
echo "Adding $addition"
ufw allow out to $addition port 22 comment GitHub
done
@cmbuckley
cmbuckley / game-of-thrones-comments.php
Last active January 17, 2020 11:46
Get all the comments from the change.org petition for Game of Thrones season 8
<?php
$base = 'https://www.change.org/api-proxy/-/comments';
$options = ['commentable_type' => 'Event', 'commentable_id' => 15409786, 'role' => 'comment'];
$complete = false;
// API blocks PHP user-agent
$context = stream_context_create(['http' => ['header' => "User-Agent: parser/1.0.0\r\n"]]);
$fh = fopen('comments.csv', 'w');
set_time_limit(0);
#!/bin/bash
fail() {
[ $raw -eq 1 ] && out=Fail || out=$1
echo -n -e "\e[91m$out\e[39m "
}
pass() {
[ $raw -eq 1 ] && out=Pass || out=$1
echo -n -e "\e[32m$out\e[39m "
#!/bin/bash
HOSTNAME=your.dns.here
UFW=/usr/sbin/ufw
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
new_ip=$(dig +short $HOSTNAME)
@cmbuckley
cmbuckley / effects.md
Last active August 4, 2025 09:09
I constantly forget which is which out of most of these.

These snippets are to highlight a minor display discrepancy between desktop and mobile link unfurling in Slack.

The article:published_time OpenGraph tag can have an optional time component. When unfurling links, desktop always treats the tag as a date, and mobile always treats it as a datetime, regardless of the content of the tag.

The content can essily be passed into Slack using raw.githack.com: