Skip to content

Instantly share code, notes, and snippets.

@peterwake
peterwake / install_hugo_0.120.3.md
Created February 22, 2025 17:06
Keeping an older version of Hugo on MacOS if Homebrew updates it

Installing Hugo 0.120.3 on macOS (Apple Silicon)

22 Feb 2025

My Hugo site stopped running locally, because Hugo and the theme I am using (Academic CV) switched dramatically from Bootstrap to Tailwind CSS, as well as a bunch of other behaviour changes. I don't have the time to update everything. But Homebrew had already updated Hugo to the latest version. And there's no option to simply tap an older version in Homebrew.

This guide documents the process of manually installing Hugo 0.120.3 on a Mac with an M1/M2/M3 processor and ensuring Homebrew does not update it. I thought I'd share it for anyone else with this problem. The usual disclaimers - you do this at your own risk, etc. etc.

0. Install the latest version using Homebrew

@peterwake
peterwake / sent-emails-summariser.scpt
Last active December 8, 2023 22:11
For Mac Mail users, summarises emails in your sent mailbox
-- Designed for Mac Mail users, this AppleScript program will search through the SENT items of your chosen mailbox
-- It is designed to help you (for example) if you are transitioning to a CRM system
-- run it by typing osascript sent-emails-summariser.scpt on the command line
-- It will produce summary csv file that shows:
-- How many emails were sent to each email address
-- How many emails were sent in total to all emails with the same domain ending
-- A domain rank whereby emails to domains ending .ac.uk, etc, rank higher
-- once you have the csv file, sort it in Excel e.g. by ascending DomainRank, descending DomainCount, Domain a-z, Count descending, Email a-z.
@peterwake
peterwake / mysql-sparse-fill-in.sql
Created November 3, 2020 12:50
MySQL query to fill in missing dates with a sparse result set
/* For a query of results in the last 31 days */
SELECT recent_dates.`date`,
IFNULL(sparse_results.`count`, 0) AS `count`
FROM
(SELECT SUBDATE(CURDATE(), number_table.delta) AS `date`
FROM
(SELECT 0 delta
UNION SELECT 1
UNION SELECT 2
// openjscad.org
// Tower Bridge
let fancy_bricks = true;
function random_colour() {
// based on 'BurlyWood';
return [
(222 + Math.random() * 10) / 255,
(184 + Math.random() * 10) / 255,
//openjscad.org
// Anna and Charlie's spral
function main () {
const twist = 45;
let i = 0;
let delta = 1;
var w = [ ];
for(var h = 0; h < 100; h++) {
w.push(
@peterwake
peterwake / structure1.js
Last active March 30, 2020 08:56
OpenJScad random structure
//openjscad.org
// Random structure
function main () {
var cube1 = cube({size:[4,4,4]}).translate([-2,-2,-2]);
var hole = cylinder({r:1, h: 4}).translate([0,0,-2]);
var nut1 = difference(cube1, hole);
var rod1 = cylinder({r:1, h: 10}).rotateX(90).translate([0,-2,0]);
@peterwake
peterwake / spiral.js
Created March 30, 2020 08:54
OpenJSCad spiral
//openjscad.org
// Anna and Charlie's spral
function main () {
const twist = 9;
var w = [ ];
for(var i = 0; i < 40; i++) {
w.push(
color('lightblue', cube({
size: [30, 6, 2]
@peterwake
peterwake / RGeo_with_Proj.md
Last active March 22, 2021 08:34
Installation of RGeo with Proj support (also called Proj4)

Installation of RGeo with Proj support (also called Proj4)

This is a real pain as of writing (18 Oct 2019). I can't promise it'll work either :)

Reference

Let's start from the beginning...

If you've been hacking around already you should do:

@peterwake
peterwake / aws_move.rb
Created December 11, 2018 16:06
AWS folder move using threading
# This is a sample class that you'll probably need
# to do a bit of work on for your own needs, but it
# will hopefully save you a lot of the headaches that we had
class AwsMove
FIVE_MB = 5 * 1024 * 1024
MAX_THREADS = 25
def move_folder(s3_client, old_key, new_key)
# strip preceding '/'
@peterwake
peterwake / haml_filters.rb
Last active March 29, 2017 13:08
Adding a :redcarpet Haml Filter to Rails 4
# config/initializers/haml_filters.rb
# Thanks to https://gist.github.com/sleepingkingstudios/955676
# config/initializers/haml_filters.rb
# in your haml files do e.g.
# %td.description
# :markdown
# #{task.description}