Skip to content

Instantly share code, notes, and snippets.

View jordancrawfordnz's full-sized avatar

Jordan Crawford jordancrawfordnz

View GitHub Profile
jordancrawfordnz / parse_disqus_json.rb
Created October 23, 2023 01:56
Fetch and parse Disqus comments
# I was struggling to get an export of my Disqus comments because their export feature never provided any results.
# I discovered (
# which is a Python script to download your Disqus comments.
# This script didn't work for me on python3 but I installed python2 and it worked fine.
# Afterwards I had a JSON dump of my comments. I wrote the below script to parse these JSON comments into a CSV
# with a thread_link and comment column.
# It's not a perfect export format (that's what the JSON is for) but it's good enough for me to read the comments.
# Run with: `ruby parse_disqus_json.rb dump.json export.csv`
jordancrawfordnz / parse_flickr_export_json.rb
Created August 27, 2023 03:29
Generate summary CSV for Flickr export
require 'csv'
ALBUMS_PATH = "[enter path here]/albums.json" # The path of the `albums.json` file
PHOTO_FOLDER_PATH = "[enter path here]" # The path where all the photo JSON files are
EXPORT_PATH = "[enter path here]/metadata_summary.csv" # The path to save the CSV export
FlickrAlbum =, :title, :description, :photos)
FlickrData =, :name, :description, :date_taken, :date_imported, :geo, :comments, :album)
# Parse photos data
jordancrawfordnz / S3-presigned-URL-issue-time-helper.rb
Last active February 25, 2023 08:07
ActiveStorage S3 - Cacheable direct presigned URLs by storing the issue time in a cookie
# app/helpers/s3_presigned_url_issue_time_helper.rb
# S3 presigned URLs include the time they're issued.
# This means if we generate a presigned URL as part of a request it'll be a different
# URL each time, making it impossible for the browser to cache.
# By default Rails mitigates this issue with the rails_representation_url - a permanent path
# for the file which redirects to the presigned URL (and can be cached just like the S3 resource)
# However, this approach results in an additional web request for each file shown on the page.
jordancrawfordnz / docker_compose.yml
Created July 19, 2021 22:18
Docker Compose example for auto renewing certs
# I use this as my most recent solution to the problems described in:
# This is an excerpt.
# To access LetsEncrypt Manager commands, use docker-compose run --rm letsencrypt <command>.
# To setup DHParams, use: openssl dhparam -out dhparam.pem 4096
version: '2'
jordancrawfordnz / drive_power_status
Last active August 31, 2020 00:48
Poll hard drive power management status.
if [ $# != 1 ]
echo "drive_power_status [name of device to watch]"
echo "Started watching $device state"
jordancrawfordnz /
Created July 27, 2019 06:19
Moving Git Repos from BitBucket to GitHub
OLD_REPO_NAME=[fill this in]
NEW_REPO_NAME=[fill this in]
USERNAME=[fill this in]
# Create the new repo in GitHub first.
# For all repos. This does a mirror clone so all references, tags, etc are migrated.
git clone --mirror$USERNAME/$OLD_REPO_NAME.git
git push --mirror$USERNAME/$NEW_REPO_NAME.git
jordancrawfordnz / Cloud tinc.conf
Last active August 26, 2017 10:15
tinc configuration for a computer at home and in the cloud
Name = cloud
AddressFamily = ipv4
Interface = tun0
jordancrawfordnz / claiming_routes.feature
Created April 1, 2017 01:22
An example of a Cucumber feature for Ticket to Ride.
Scenario: The player uses their turn to claim a route and the route appears as claimed.
Given a game with 5 players is setup
And the player has 5 train pieces
And the player has 5 "Hopper" train cars
And the player navigates to the game page
When the player clicks the claim route button on a route between "Vancouver" and "Calgary"
And the player selects 3 "Hopper" train cars
And the player clicks the "Claim Route" button
Then the player is on the game page
And the player sees the route from "Vancouver" to "Calgary" claimed with their name
context "on ClaimRoute failure" do
let(:service_double) { instance_double(ClaimRoute, call: service_result, errors: service_expected_errors) }
let(:service_result) { false }
let(:service_expected_errors) { [ClaimRoute::REQUIRED_PARAMETERS_NOT_PROVIDED] }
before do
it "redirects to the game page" do