quantenbrot

September 1

Tiling an image for emoji-lols

convert monalisa.jpg  -crop 128x128 +repage m_%02d.png

This will:

  • Generate 128x128 tiles of the image monalisa.jpg
  • Save them as sequentially named files m_(number).png with 2 wide padding, e.g. 01 instead of 1
  • Repage the image, meaning the virtual canvas gets reset to avoid possible display issues

August 14

Fixing mkv files

I have a bunch of mkv files with foreign audio, but the subtitle track doesn’t have a language set, so Plex doesn’t know it should auto-select the subtitles.
I finally found a solution: Good ol’ mkvtoolnix, or mkvpropedit to be exact.

Just run this in the folder with the offending files:

for file in $(ls *mkv); do 
    mkvpropedit $file --edit track:s1 --set language=en; 
done

This sets the language of the first subtitle track to english.

See also the official docs

Fixing Mendeley's BibTeX export

I’m writing my bachelor’s thesis with LaTeX and Mendeley as a reference manager. Ever since I switched from BibTeX to BibLaTeX, I’ve been getting warnings about the month formatting in my .bib file. Long story short, Mendeley saves month = {jan}, but BibLaTeX wants month = jan. So that’s one thing to fix. Another thing is just a cosmetic thing, but the Mendeley export starts with a message about the .bib file being auto-generated and such, so yeah.
Anyway, fixing that is easy enough using good ol’ sed. There’s probably better ways to do this, but this one works and it’s simple to understand:

#! /usr/bin/sed -f

s/{jan}/jan/g
s/{feb}/feb/g
s/{mar}/mar/g
s/{apr}/apr/g
s/{may}/may/g
s/{jun}/jun/g
s/{jul}/jul/g
s/{aug}/aug/g
s/{sep}/sep/g
s/{oct}/oct/g
s/{nov}/nov/g
s/{dec}/dec/g

1,5d

Saving that as cleanbib, chmod +x to make it executable, and that’s it. Just pump your .bib file through it, save and done.

August 9

I hate computers

So after upgrading to the a bit beta-y FreeNAS 11.2 (BETA1), I was happy at first because everything worked well. The switch from warden to iocage gave me an opportunity to set up fresh jails with less “is this how you install ports?”-baggage and stuff, and since my jails were leftovers from FreeNAS 9.3, it was time for an upgrade anyway.

After I set up all the things using the iocage jails running in 11.2, I ran into the first issue: A bug that caused iocage to be confused about OS version, thinking its host is 11.1, which meant the 11.2 jails wouldn’t run. After way too much tinkering and googling I managed a dirty fix (manually editing the jails config.json to make it think it’s 11.1), but that bug was fixed in BETA2 and all was well.

Then the next fuckup: iocage creates its own dataset for config and jails, and that dataset was stored on my secondary ZFS pool which is an external HDD I only have plugged in for testing/outsourcing/buffer stuff, so that was no good.
I tried various things to migrate iocage to the proper pool, but it didn’t really work and I just gave up and recreated all my jails on the now moved iocage dataset. Good thing I started documenting all the things I needed to do/install in a text file in case that happened again, because today, just a few days after the second “I gotta reinstall everything”, I tried upgrading my NAS’ RAM, but learned the hard way that my RAM was not supported. Soooo, yeah, reinstalling the old RAM, reboot, no biggie, right?

Right. For some reason or another, some of the iocage shenanigans from the previous issue seemed to trickle down, I don’t really know what happened but iocage ate all it’s jails. It was still active on the correct pool/dataset, but all the jail folders were empty for fuck knows what reasons.

So yeah, I reinstalled everything again. By this point, it only takes me about an hour to reconfigure and reinstall all the things. Here’s the rough list:

  • Create 3 jails:
    • plex
    • lobby (for sonarr, radarr, tautulli, general purpose stuff)
    • jackett
  • Install resilio sync plugin (because there’s no pkg available and I’m lazy)
  • Create mount points for media and appdata dataset for each jail. The latter stores application data and some config backups
  • In all jails, install nginx, set up reverse proxies for all services to be neat in my LAN
  • Install all the things
  • In some cases, move modified rc-scripts into place (/us<TAB>loc<TAB>rc.d/ is engrained in my hands now)
  • reconfigure resilio sync
  • reconfigure syncthing
  • set up ssh in lobby and plex again

… That’s it, roughly. And boy do I wish I had the time to learn how to automate all that shit with iocage, because I know it’s possible… somehow.

August 8

Can I use this for R snippets?

Well the first problem would be me having small snippets of R code that would be cool. The next problem would be appropriate syntax highlighting.

runs %>%
  arrange(time_primary) %>%
  head(20) %>%
  select(submitted, time_primary, player_url) %>%
  mutate(time_primary = hms(seconds = time_primary)) %>%
  kable()