After many years of supernaut images being tiny wi…


After many years of supernaut images being tiny with ragged right background captions, I’ve been slowly ditching it for supernaut teenage Instabanga big images. And finally I cleared out all the old styles and code, made new medium and large image galleries, redid the styles and scripts repeatedly, said goodbye to funky bodges. Kept the blazing deep pink tho’. 😍🤘💥❌💯‼️

生日快乐!!! Happy 14th Birthday supernaut! 🤘🎂🎉🔥💥🖤

One day late celebration of supernaut’s 7th April birthday. Supernaut is fully a teenager now, emoji-ing and posting images like she thinks this is Instabang. Emile said supernaut is a life-project now.

Hacking & Bodging a Git Hook + Vagrant + WP-CLI + Bash Local to Dev Database Transfer

Ever since I started using Git to push local website changes to a development server, I’ve been vaguely irritated about dealing with the database in the same manner. For a long time, I used interconnect/it’s Search Replace DB for this side of things, but I was always wondering if I could somehow increase laziness time by automating the process. One hungover Sunday, plus a couple of hours on Monday, and one hacked and bodged success.

This isn’t a “How to do yer Git + Vagrant + local to dev” thing, nor is it a copy-paste, “Works for me!” party. Nonetheless, provided you’re using git-push, and are comfortable with WP-CLI or MySQL command-line, Bash, and generally thrashing small bits of code around, in principle it would work in any situation. And I do feel kinda dirty throwing all this into Git post-receive, but whatever seems to work.

So, here’s what I wanted to do:

  1. Do all my commits, and run git-push and throw all the file changes to the dev server.
  2. Combine that with a dump of the database, then get it to the dev server.
  3. Use something at the other end to import the database, and search-replace strings
  4. Clean up after at both ends.

When I first looked into this, it seemed using the pre-commit Git hook was the most common approach, dumping the database and adding it to the commit. I didn’t want to do this, for a couple of reasons: I do a lot of commits, and the majority have no database component; I wasn’t looking to version control the database; All I wanted to do was push local to dev database with the changed files. Looks like a job for pre-push hook.

Earlier this year, I started using Vagrant, so the first issue was how to dump the database from there. I do commits from the local folder, rather than SSH-ing into the VM, so mysqldump is not going to work without first getting into the VM. Which brought its own set of weirdnesses, and this was the point when I decided to flop over to WP-CLI, the WordPress command-line tool.

I often find solutions to this sort of thing are dependant on the combination of software and commands being used. I use mysqldump on its own all the time, but here, I needed to use Git to set the path for where the database would be dumped to — because git hooks are in a sub-directory of the git folder — and that, in combination with dumping the database inside the VM while within a Git command running from the local folder (yeah, probably should just do all my git via SSH), and hurling it at a remote server, means sometimes things that work in isolation get cranky. And this is a hack/bodge, so I went with:

  1. Set up paths for the database dump with Git, ’cos Git is running this show.
  2. SSH into the Vagrant box.
  3. WP-CLI dump the database to a gzipped file.
  4. SCP that up to the dev server.
  5. Delete all that on the local server, ’cos I’m tidy.

That’s half of it done. I’ve got my pushes working, the database file is up on the dev server, the local server is all cleaned up, so now it’s time for the other end.

In this case, I was doing it for a site on DreamHost, who conveniently give all kinds of fun command-line access, plus WP-CLI on their shared servers. Once Git has finished checking out the new file changes in post-receive, it’s time for frankly bodging it.

My current usual setup is a bare repository on the dev server, which checks out to the development website directory. This means neither the uploaded database, nor WP-CLI and the WordPress root are in the same place as the running hook. No big deal, just use –path=. The next thing though, is cleaning up post-import. Strings to be changed all over the place, like local URLs swapped to dev. And for that we have, wp search-replace, which is an awful lot like Search Replace DB. At the dev end then:

  1. Set up paths again, this time it’s WP-CLI running the show.
  2. Unzip the database then import it.
  3. Do database stuff like search-replace strings, and delete transients.
  4. Delete that uploaded database file on the dev server, ’cos I’m tidy.

I was looking at all this late last night, all those repeating lines of ‘wp search-replace’ and I thought, “That looks like a job for an array.” Which led me down the tunnel of Bash arrays, associative arrays, “How can I actually do ‘blah’, ’cos bash seems to be kinda unwilling here?” and finally settling on not quite what I wanted, but does the job. Also, bash syntax always looks like it’s cursing and swearing.

The pre-push hook:


# a pre-push hook to dump the database to a folder in the repo's root directory, upload it to the dev server, then delete when finished

echo '***************************************************************'
echo 'preparing to back up database'
echo '***************************************************************'

# set up some variables, to keep things more readable later on
# backup_dir is relative to git hooks, i.e. 2 directories higher, so use git to set it

ROOT="$(git rev-parse --show-toplevel)"

# check there is a database backup directory, make it if it doesn't exist then cd to it

if [ ! -d "$BACKUP_DIR" ]; then
mkdir "$BACKUP_DIR"

# cos this is vagrant, first ssh into it. there will be a password prompt
# using EOF to write the commands in bash, rather than in ssh quotation marks

ssh -t vagrant@ << EOF

# cd to the new databases folder. this is absolute, cos is vm and not local folder
cd "/var/www/user/domain.tld/.database" 

# then export the database with wp-cli and gzip it
wp db export --add-drop-table - | gzip -9 > $DB_NAME.sql.gz

# exit ssh

# bail out of eof

# scp the backup directory and database to dev server
scp -r $BACKUP_DIR user@domain.tld:~/

# remove that backup directory so it's not clogging up git changes

echo '***************************************************************'
echo 'all done, finishing up git push stuff'
echo '***************************************************************'

The post-receive hook:


echo '***************************************************************'
echo 'post-receive is working. checking out pushed changes.'
echo '***************************************************************'

# check out the received changes from local to the dev site
git --work-tree=/home/user/dev.domain.tld  --git-dir=/home/user/.repo.git checkout -f

# import the database with wp-cli
echo '***************************************************************'
echo 'starting database import'
echo '***************************************************************'

# setting up some paths
# on some webhosts, e.g. all-inkl, setting the alias to wp-cli.phar is required, uncomment and set if needed
# alias wp='/path/to/.wp-cli/wp-cli.phar'

# the path to wp-config, needed for wp-cli
# database directory, created in git pre-push

# check there is a database directory
if [ -d "$DB_DIR" ]; then

	# then check it for sql.gz files
	DB_COUNT=`ls -1 $DB_DIR/*.sql.gz 2>/dev/null | wc -l` 

	# if there is exactly 1 database, proceed
	if [ $DB_COUNT == 1 ]; then

		#grab the db name, this way the db name isn't hardcoded
		DB_NAME=$(basename $DB_DIR/*)

		echo 'importing the database'
		echo '***************************************************************'

		# unzip the database, then import it with wp-cli
		gunzip < $DB_DIR/$DB_NAME | wp db import - --path=$WP_PATH

		# clear the transients
		wp transient delete --all --path=$WP_PATH

		# run search replace on the main strings needing to be updated
		# make an array of strings to be searched for and replaced

		#loop through the array and spit it into wp search-replace
		for (( i=0; i < ${#search[@]}; ++i )); do
			eval wp search-replace --all-tables --precise \"${search[i]}\" \"${replace[i]}\" --path=$WP_PATH

		# any other wp-cli commands to run
		wp option update blogname "blog name" --path=$WP_PATH

		# delete the backup directory, so there's no junk lying around
		rm -rf $DB_DIR
		echo 'database was not found'
		echo '***************************************************************'


	echo 'database folder was not found'
	echo '***************************************************************'


echo '***************************************************************'
echo 'all done'
echo '***************************************************************'

What else? Dunno. It’s pretty rough, but basically proves something I didn’t find an example of all combined into one: that you can use git hooks to push the database and file changes at the same time, and automate the local-to-dev database transfer process. Is this the best way to do it? Nah, it’s majorly bodgy, and would have to be tailored for each server setup, and I’m not even sure doing such things in a git hook is advisable, even if it works. It does demonstrate that each step of the process can be automated — irrespective of how shonky your setup is — and provided you account for that and your own coding proclivities, there’s multiple ways of doing the same thing.

(edit, a day later.)
I decided to throw this into ‘production’, testing it on a development site I had to create on webhost I’m not so familiar with but who do provide the necessities (like SSH and Let’s Encrypt). Two things happened.

First, WP-CLI didn’t work at all in the post-receive script, even while it did if I ran commands directly in Terminal (or iTerm as I’m currently using). After much messing about, and trying a bunch of things it turned out that this was an issue of “has to be tailored for each server setup”, in this case adding an alias to wp-cli.phar.

Second, having a preference for over-compensation while automating, it occurred to me that I’d made some assumptions, like there’d only be one database file in the uploaded directory, and that hardcoding the filename — which was one of those “I’ll fix that later” things — had morphed into technical debt. So, feeling well competent in Bash today, I decided for the “make sure there’s actually a database folder, then check there’s actually a sql.gz file in it, and there’s only one of them, then get the name of that file, and use it as a variable”. I often wonder how much of this is too much, but trying to cover the more obvious possible bollocks seems reasonably sensible.

Both of these have been rolled into the code above. And as always, it occurs to me already there’s better — ‘better’ — ways to do this, like in pre-push, piping the database directly to the dev server with SSH, or simultaneously creating a separate, local database backup, or doing it all in SQL commands.

Reading … A 10th Anniversary

Another year of reading. Ten years I’ve been at this, blogging every book I read (almost every, a few slipped by over the years). Going from just blogging the book covers, to a few lines on why I was reading, to my recent frankly absurd multi-thousand word essays on some of Iain (M. or not) Banks novels. Trying to rein in that latter particular excess.

Usually at this point, I look at what I wrote a year ago, so I can aim for some sort of consistency.

A lot of fiction this year, almost twice as much as non-fiction, for a total of 34 books read — or attempted, I gave up on a few, and there’s a couple that I’ve already started but won’t make this list, ’cos I haven’t blogged them yet. Blogging is reading, just like rubbing is racing.

The year got off to a brilliant start with three biographies by trans women: Janet Mock’s Redefining Realness: My Path to Womanhood, Identity, Love & So Much More, Laura Jane Grace’s Tranny: Confessions Of Punk Rock’s Most Infamous Anarchist Sellout, and more a collection of essays over decades that becomes biographical, Julia Serano’s Outspoken: A Decade of Transgender Activism and Trans Feminism. And Tranny is my Book of the Year. There’s a couple of others equally or maybe more deserving — thinking of recent reads Peter Fryer’s Black People in the British Empire: An Introduction and China Miéville’s October: The Story of the Russian Revolution — but Miéville’s had a couple of Books of the Year already, so that’s him out. Tranny just spoke to me on a very personal level (as did Redefining Realness, different but no less personal), and Laura Jane Grace has been making miles in my head all year, I’m listening to her now. I’d marry her, it’s that kind of thing.

Following that trio, I went straight into Gayatri Chakravorty Spivak’s An Aesthetic Education in the Era of Globalization. Still in it. Not an easy read, needs the kind of mental preparation and focus I’ve been lacking the last some years, though strangely not for Caroline Walker Bynum, who I’ve been reading for three years now, one of my absolute loves, and Christian Materiality: An Essay on Religion in Late Medieval Europe is also deserving of being a Book of the Year.

A couple of others on the non-fiction side: May Opitz, Katharina Oguntoye, Dagmar Schultz (eds.) Showing Our Colors: Afro-German Women Speak Out, I read after seeing it at Deutsches Historisches Museum’s Deutscher Kolonialismus: Fragmente Seiner Geschichte Und Gegenwart exhibition. I’m didactic and prescriptive, and just like Peter Fryer, this (or whatever more recent work) should be compulsory reading in Germany, along with Ruth Mandel’s Cosmopolitan Anxieties and Katherine Pratt Ewing’s Stolen Honor — and a bunch of other stuff. But the last year’s European, American, and Australian politics makes me think we haven’t got a chance, walking with their eyes open while we shout and plead with them against where they’re going, where they’re dragging us.

I haven’t been reading much on China lately (or Afghanistan for that matter, but remedying that at the mo), but did read Frank Dikötter’s The Cultural Revolution: A People’s History, 1962–1976, the final work in his China under Mao Zedong trilogy (preceded by The Tragedy of Liberation and Mao’s Great Famine). He’s one of the few historians writing on China I’ll always read, who’s also in the fortunate position to be able to publish semi-regularly (and for academic publications, not horrifically over-priced).

There were a few other non-fiction works, but let’s get onto the fiction, or science-fiction and fantasy, ’cos I still don’t read anything else. I went on a lengthy Iain M. (plus a couple of non-M.) Banks binge earlier this year. I needed to just read, eyes rush over the pages, know before I started I’d love the story, sink back into familiar worlds and lives. Obviously that mean starting with my favourite book ever, Feersum Endjinn, and this being my first Banks re-read in some years, I came to him with a tonne of new reading behind me, and wow did I ever write about all my new thoughts. I followed that up with Whit, which has never been one of my favourites, nor did I think of it as one of his best. Wrong again, Frances. Back to The Business after that, definitely one I adore, and have read at least 6 times, then back into his skiffy with the late / last trio: Surface Detail, The Hydrogen Sonata, and Matter. I feel a little unsure putting these in my year’s reading here, as though there’s nothing remarkable about reading him multiple times, or that this is supposed to be about new books I’ve read. On the other hand, fuck it, it’s my blog and my reading and I can fuck off if that’s the attitude I’m going to bring.

There was a sizeable dip early- to mid-year, disappointment in fiction, feeling apathetic about the heaviness of non-fiction (thanks, Twitter), and also perhaps just steamrolling through scores of books year after year is an unrealistic monotone that I’m not. I did have a thrill with one more of Steph Swainston’s Castle novels, Fair Rebel, followed almost immediately by Above the Snowline, and love that she decided to return to writing, ’cos she’s one of the best. Not easy, these are large, demanding works that don’t mainline narrative reward, but she’s got one of the most captivating and extensive fantasy worlds I’ve read.

At the same time as Swainston, I got my grubby mitts on Alastair Reynolds’ Revenger. Something of marketed as Young Adult (is not), and not especially long (longer though than his novella Slow Bullets), and it feels like a Girl’s Own bit of romp, then he massacres an entire ship’s crew and continues in his very, very dark and existentially terrifying way right up till the end. Book of the Year for me, right there. Then there was the aforementioned Banks tour, and not until I was in Brussels did I get mad thrilled about fiction again. Cheers, once again, Gala. Ben Aaronovitch’s PC Grant series, A young Idris Elba / Stormzy cop with Harry Potter powers. A more cheerful Liminal People series. I started with number 2, Moon Over Soho, which meant reading the first in the series, Rivers of London had both plenty of, “I know who these people are,” and “Oh shit, her face is gonna fall off, isn’t it?” I’ve got the other 5 in the series on order.

I get to this point of writing, and I’ve added the covers of all these books, so I’ve got a nice visual treat in front of my mug, and I scroll through them … smiles all the way. And a little shiver of goosebumps. I’m lucky as all shit to be able to buy new books almost every week even when I’m on the verge of poverty (cheers, Germany and your incomprehensible to Australia attitude to cheap books), and lucky as all shit to have the time and education and all the rest to be able to read them. It’s a human right and every day I give thanks to the people (shout out to Eleanor Roosevelt here!) who fought and continue to fight for our inalienable rights.

Maybe I’m going to make this a thing (which always feels contrived), but I’ll finish quoting myself again, first from 2013 and then from 2015:

Buy books! Buy books for your friends! Encourage people to read. If you know someone who Can’t Read Good (And Wanna Learn To Do Other Stuff Good Too), help them, reading is only difficult if you’ve been told it is. Support your local libraries!


So here’s to the writers, and their publishers and proofreaders and editors and typesetters and designers and artists and agents and friends and families who make it possible for them to write so that I may read.

And speaking of designers and artists, I decided to do a Book Covers of the Year thing, dunno why I haven’t before now. Mainly because both Revenger and October have covers that smash it. Also the original Feersum Endjinn, class late-20th century sci-fi cover art there.

Thrilled and awed by all this reading? Here’s the last years’ anniversary lists:

5-Character Dev Environment

Messing with my .bash_profile this afternoon, post-diving into Laravel and Git (which I’ve been doing much of the last week), I realised I could boot my entire dev environment with 5 letters. Fewer, if I wanted.

So instead of going to the Dock, clicking each of the icons, going to each and faffing around, I could at least boot them all, and set off some commands in Terminal (or ITerm2 as I’m now using).

Weirdly, until Justine gave me an evening of command-line Git learning, and wanted my .bash_profile, “Like so,” I hadn’t realised you could do stuff like that, despite amusing myself with all manner of shell scripts. Now I know what’s possible, I’m over-achieving in efficient laziness.

What’s missing is:

  • Opening multiple windows in ITerm or Terminal and running a different command in each (I don’t want to boot multiple instances of an app).
  • Setting off a menu action in an opened app, e.g. in Transmit going to my work drive.
  • Extending it to boot the environment and then a specific project, e.g. “devup laravel” would open my laravel installation in each of the apps, like opening the database in Sequel Pro; cd-ing to the laravel folder after automatic SSH-ing into my Vagrant box, and so on.

Some of these are probably uncomplicated, but this was a 30-minute experiment that turned out to be very useful.

Bookmark Archaeology


I was cleaning out my browser bookmarks last night, first time in years, bookmarks going back to the early-’00s, thousands of them. I opened them in batches, every one, to see if I wanted to keep them. Hundreds, thousands of dead sites, no longer found, no longer existing. All that history and culture vanished as if it never was, only the link and title in my bookmarks proving they once existed, and once I deleted that …

Code Stupidity


I got sick of the tiny, Web1.0 images everywhere here, a hangover from the earliest days of supernaut, so I decided — ’cos I like visuality & pix — to make small, big. I thought it would be easy. Little did I know I also create and add to the pile of Technical Debt. So: most single images in the recent past are now huge-ified, 666px wide; recent image galleries which are not full of diverse image ratios are now evenly splitting the Number of the Beast. Older images and galleries should be retaining their previous diminutiveness, but who knows, 13 years of blog is difficult to homogenise. Mostly I got distracted with how to make portrait images not blow out of the available browser window space, which turns out to be a kinda traumatising process I didn’t achieve. Plus how to Lazy Load srcsets by preg_replacing the new WordPress caption shortcode. OMFG, Frances, WTF? All of which makes me think it might be time for yet another supernaut refresh. So much code. So many images. So much …