Skip to content

Instantly share code, notes, and snippets.

Chris Buckley cmbuckley

Block or report user

Report or block cmbuckley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cmbuckley
cmbuckley / test-old-usertrust.sh
Last active Feb 18, 2020
Check for old USERTrust intermediate certificate
View test-old-usertrust.sh
#!/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 Jan 20, 2020
Update UFW with IPs from GitHub
View update-ufw-github.sh
#!/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 Jan 17, 2020
Get all the comments from the change.org petition for Game of Thrones season 8
View game-of-thrones-comments.php
<?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);
View summary.sh
#!/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 "
View ufw-dynamic-dns.sh
#!/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 Dec 13, 2019
I constantly forget which is which out of most of these.
View effects.md
View README.md

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:

@cmbuckley
cmbuckley / sms.sh
Created Oct 10, 2019
Nexmo SMS script
View sms.sh
#!/bin/bash
function msisdn() {
sed 's/^0/44/' <<< "$1"
}
API=https://rest.nexmo.com/sms/json
KEY= # Nexmo API key
SECRET= # Nexmo API secret
DEFAULT= # Default SMS sender
View README.md

This is just an example for https://stackoverflow.com/q/58283005/283078.

The following commands were run to create this history:

git checkout -b dev
git commit --allow-empty -m 'Dev commit 1'
git commit --allow-empty -m 'Dev commit 2'
git commit --allow-empty -m 'Dev commit 3'
git checkout master
@cmbuckley
cmbuckley / fd.sh
Last active Jun 12, 2019
Firedrill script
View fd.sh
#!/bin/bash
webhook_url="URL HERE"
role=Firedrill
icon=bust_in_silhouette
channel="#lotto-support-3p"
roles=(
"marketing,Marketing:female-technologist::skin-tone-2"
"crm,CRM:male-singer::skin-tone-3"
"core,Core on-call:bearded_person::skin-tone-2"
You can’t perform that action at this time.