Pragmatism in the real world

Sleeping an external hard drive

One annoyance I had with my external USB hard drives is that they weren't sleeping when idle which makes them noisy. We can't have that! My first port of call was hdparm and its -S parameter: sudo hdparm -S 60 /dev/sdb However this didn't help. Fortunately, I found hd-idle which worked! After installing, you need to edit /etc/default/hd-idle and change the HD_IDLE_OPTS setting from -h to whatever you need. For me, I have set: HD_IDLE_OPTS="-i… continue reading.

Setting up a new hard drive in Linux

I recently added a second SSD to my Linux server and had to look up how to format it and set it up, having not taken notes for the first one. These are the notes I took the second time. This is all done from the command line and the monospace text is to be typed directly – though change the identifiers if requried. sudo lshw -C disk to confirm disk is seen by the… continue reading.

Using GitHub Actions to add Go binaries to a Release

Shortly after building a script to create binaries for Rodeo, my command line Flickr uploader, I realised that I could use a Github Actions workflow to run it and attach the created binaries to the Release page once I had created it. This is what I did. Trigger on release A GitHub Actions workflow is a YAML file and each workflow has to be triggered. For Continuous Integration, it's common to trigger when new PR… continue reading.

A few thoughts on conferences

Last week, I attended PHPUK 2024. This is one of the major PHP conferences and I was pleased to speak about DDD there. Sam and the team did a fantastic job this year with the videos already published. To my mind, attending a conference provides a number of benefits. The first and most obvious one is that you learn some amazing things, from people who tend to know what they are talking about. At PHPUK… continue reading.

Building Go binaries for different platforms

One nice thing about Go is that it can cross-compile which allows me to use my Mac to build binaries for different operating systems. This is increibly useful for providing binaries for Rodeo, my command line Flickr uploader. To do this we set the GOOS and GOARCH environment variables before calling go build. For example to build for x64 on Linux, I do: version=`git describe –tags HEAD` env GOOS=linux GOARCH=amd64 go build \ -ldflags "-X… continue reading.

Setting the version of a Go application when building

When I was building Rodeo, my command line Flickr uploader, one thing I wanted to do was set the version number that you see when you type rodeo -v to the correct version when I build the application for release. The basic process I wanted was: Tag git repository with new version number and push Build rodeo with that version without editing any files Upload binary I've emphasised the important part. I don't want to… continue reading.

Backing up to an external HDD using rsync

I have a Linux-based server that acts as my Plex server amongst other things. It's fanless and I added an additional SSD for to hold the media data so it is nice and quiet. I'm a little bit of a belt-and-braces person when it comes to backing up my data, so in addition to backing up to the cloud, I also back up the data from the SSD to an external HDD every night using… continue reading.

Uploading to Flickr directly from Mac Finder

I upload lots of pictures to Flickr and sometimes I just want to point at a file in Finder and upload it. Fairly recently, macOS introduced Quick Actions to Finder and this seemed like the ideal way to have a quick and easy way to upload an image to Flickr. To do this, the easiest way is to use Automator and call through to my Rodeo command line tool to do the actual upload. Start… continue reading.

Darkening an image with ImageMagick

I regularly need to darken images for background use behind a title. I've been using a filter in Acorn, but finally decided to make it a script that uses ImageMagick so that I could simplify it all with Alfred. This is the script: darken-image.sh #!/usr/bin/env bash if [ -z "$1" ] then echo "Usage: darken-image [contrast=40]" echo "" exit 1 fi in_filename="$1" amount=${2:-40} # Set output filename to original filename with "-darker" appended extension="${in_filename##*.}" name="${in_filename%.*}"… continue reading.

Updating Flickr metadata using Python

I usually use my rodeo app to upload photos to Flickr, but for various reasons, I recently uploaded some photos directly via Flickr itself. One feature of rodeo that I really like is that it sets the date posted to be the same as date taken which means that they are ordered correctly in my photo stream. As this doesn't automatically, I knocked up a Python script to fix these photos for me. The key… continue reading.