Get breakdown of UK and non-UK votes for a Parliamentary Petition (Python)

For various reasons today it's been interesting to pull out what proportion of signatures on a given Parliamentary petition (i.e. one on https://petition.parliament.uk) came from outside of Great Britain.

Petitions are open to British Citizens, including those living overseas, so it's expected that there will be some signatures from other countries, without there being any foul play, this python3 script just helps assess the proportion.

Read more…

Decompress Mozilla Firefox jsonlz4 bookmark backup files (Python)

Sometimes you need to extract something from Firefox without actually running it (as an example, I sometimes need to access stuff in firefox on a remote machine, whilst I can run firefox over a SSH tunnel with --no-remote, there's currently no way to prevent Firefox from restoring whatever tabs were previously open, other than turning it off in about:config, which is crap for day to day usage).

Firefox currently uses files of type mozlz4 (Basically a non-standard variation of lz4)

This snippet will decompress those files and print the output to stdout, so that the JSON can then be passed into something else (or grepped, etc)

Read more…

Rsync over SSH with a custom port (BASH)

It's not at all uncommon nowadays for SSH not to be listening on TCP 22, but to instead be bound to another port - primarily to prevent brute force attacks by the various dumbest-of-the-dumb bots out there

Occasionally, though, you then want to use rsync over an SSH tunnel, and need to specify the port to use so that rsync uses the custom SSH port instead of port 22

It's pretty straightforward, but is one of those things I use infrequently enough to need to look it up from time to time

Read more…

Remotely backing up PFsense Configuration (BASH)

I like PFsense. It's achieved the goal of being a good firewall, allowing complex rules, without being too much of a pain to manage.

However, being a firewall, it does live it's life on the edge exposed to miscreants and users alike, so I like to make sure the configuration is automatically backed up (pulling into a git repo also means you can receive notifications when the config changes)

There isn't an easy and direct route to remotely pull a backup, so this snippet provides functions to allow you to do so from BASH scripts. Because it's effectively reliant on scraping, there is some variation between PFSense versions

Read more…

FFMPEG: Converting RMVB to X264 MP4 (BASH)

If I'm honest, I'd forgot that Real Media Variable Bitrate was even a thing. Which is probably for the best as it's best left buried in the shrouds of time

Unfortunately, whilst sorting some old files, I found a bunch that were in RMVB format, so wanted to convert them to something a little more sane (and more widely supported) without sacrificing quality

This snippet details how to convert a directory of RMVB format files to X264 MP4's with MP3 Audio

Read more…