As I mentioned on previousoccasions, I don’t take too kindly to people trying to make me pay once for a game and again for its soundtrack and, as a matter of principle, I rip my soundtracks straight from the data files I paid for rather than pirating the officially separated versions.
Not much to report over the last few days. I was mainly busy ripping old CDs so I could store them in the closet.
cdparanoia -B and ddrescue (instructions) are essential for damaged audio tracks and CD-Rs. However, for old DOS/Win3.1-era CD-ROM games which use Redbook audio, they don’t really produce something that DOSBox or CDEmu+Wine can mount and play.
As such, I whipped up a quick little script for generating BIN/CUE pairs based on advice for ripping Playstation games under Linux. Here it is in case anyone wants it (you’ll also want my swab.py script that works but is long overdue for a rewrite):
In the time since I last tried migrating my blog to Jekyll, it has gained an official WordPress importer. Unfortunately, that importer requires direct database access and NearlyFreeSpeech.NET doesn’t have the requisite Ruby dependencies.
…so I decided to hack around that. It’s much easier to run the importer locally, but NFSN doesn’t expose their database servers to the world at large… SSH port forwarding to the rescue.
Install the development headers for libmysqlclient
gem install jekyll-import sequel mysql2 unidecode` Note: Make sure it does complain about `htmlentities` being missing or you’ll get a broken import with things like the / in </a> escaped.
Open up two terminal windows
In one terminal, adjust this SSH command and run it to forward the MySQL client port ssh -L 3306:YOUR_DSN_HERE:3306 USERNAME_SITENAME@ssh.phx.nearlyfreespeech.net
In the other terminal, adjust and run this jekyll-import command to dump the blog
Note: Make sure `host` is set to 127.0.0.1. If you use localhost, it will try to use a UNIX domain socket rather than a TCP socket and fail.
Exit the ssh connection to close the tunnel and start fine-tuning the exported content.
Unfortunately, I found jekyll-import insufficient (eg. it made no attempt to preserve permalinks) so I started investigating alternatives. I discovered that Pelican (a Python alternative to Jekyll) has some very appealing plugins (eg. ), so I’ll probably use that instead.
I generally like using TaskWarrior to manage my tasks but I’ve found that, for daily recurring stuff, it just doesn’t feel quite right.
As such, I’ve put together a little tasklib-based glue script, runnable as a user cronjob if you set DISPLAY, which presents tasks due before the end of today (defined as 1:00:01 AM, local time, to work around a quirk caused by TiddlyWiki’s ignorance of daylight saving’s time) in a zenity checklist dialog.
It looks like this:
Clicking OK will commit the changes and then redisplay the dialog with refreshed content while clicking Cancel will quit the tool. The redisplay behaviour, window size, warning period, and zenity command can be customized by editing constants at the top of the file.
It’s available on GitHub Gist, as embedded below and here’s the download link. A requirements.txt is included which will install all of the dependencies except zenity.
Today, I decided to help someone out and, as is often the case with coding, I got carried away.
I set out to help fix up a shell script but, instead, I decided to “do it right” and produced a simple Python script which…
Uses a combination of GLib.timeout_add_seconds and UPower events to react to power supply changes immediately while still putting a limit on how often battery percentage changes should be able to cause wakeups.
Uses GStreamer and notify2 to provide audio and visual low-battery warnings without the weight and delay of calling subprocesses.
Is compact and easy to customize because it’s written in Python
By design, it doesn’t really have much of a UI (just a persistent notification popup and alert sound that come and go in response to changes in power state), but here’s what the popup looks like when using xfce4-notifyd:
It does require the 1.0 UPower API for its “Display Device” abstraction, so an 0.99.x-series version of UPower or newer is required, but for people on a new enough Debian/Ubuntu/Mint release (Vivid, in Ubuntu’s case), the dependencies can be installed as follows:
It hasn’t been tested under Python 3.x but it looks like it should work perfectly if you just replace python-notify2 python-gi with python3-notify2 python3-gi in the dependencies and edit the shebang line at the top of the file.
I only wish I’d realized what I was doing sooner so I could start tracking its evolution properly in git. As-is, all I could do was translate the snapshots from Dropbox’s revision history.
As usual for small, single-file things, here’s the direct download link followed by a GitHub Gist embed.
Last night, I was working on a bunch of images and I really wanted to just get a visual overview along the lines of a scatter plot, but with images rather than dots. Unfortunately, no matter what I searched for, I couldn’t find anything to do what I wanted.
ImageMagick’s montage tool can do it… but you have to manually fill in the empty cells with the special filename null:
…so I wrote a script to do just that.
Oh, and I got carried away and wrote a “rubber matrix” class to abstract away the actual generation of the grid. Basically, it’s a DictMixin-based class that insists on consistently sized tuples as keys and then adds some extra methods to traverse them as sparse points in a matrix dynamically sized to only the rows/columns/etc. which exist.
I haven’t yet decided on what command-line syntax I want, so you have to import it, but it works perfectly in my preliminary tests.
TL;DR: Use this script. Non-Linux users, feed it the path to a sessionstore JSON file. Try --tiddlywiki for more copy-pastable output.
Because of the relatively high UX overhead of things like Firefox’s built-in bookmarking or Delicious.com, I recently found myself with over 1000 tabs in my Firefox tab groups.
Lazy-loading after a browser restart or not, this was very far from ideal so I whipped up a quick little script which contains not only the code I used to dump my sessionstore.js, but also the code I used as an aid to reverse-engineering the tab groups part of it since, as far as I can tell, the Mozilla guys didn’t bother to document that.
The code’s definitely not pretty and I can’t guarantee the --make-schema and --check-schema parts still work, but the dumping works perfectly and I didn’t want to spend too much time on it because I’ve heard Mozilla wants to move away from JSON for saved sessions in favour of a custom binary format specifically designed to help them minimize the amount of time internal data structures need to stay locked in order to write them out on a potentially memory-constrained device. (Remember, Firefox on Desktop shares code with Firefox OS.)
It was originally developed to operate on sessionstore.js but, between when I started developing it and now, things changed a bit so, now, it reads sessionstore-backups/recovery.js instead.
It can take one or more paths but, if you don’t provide one, it’ll assume a Linux desktop and try to export every tab group from every Firefox profile in your user account. As written, it always dumps to the tabs.html file in the current working directory.
Normally, it produces a nice-looking HTML output, complete with favicons for list bullets but, If you pass the --tiddlywiki option, it’ll generate a nice compromise that can be copy-pasted into TiddlyWiki. (Including hidden !!! prefixes for the headers so that you can copy-paste a bunch of groups in one go.)