duncanlock.net

As I mentioned previously, this site was put together using Pelican - a static site generator, written in Python.

Blueprint style diagram showing a brown Pelican
Figure 1. Pelecanus Occidentalis - the Brown Pelican. Original clipart Flying Pelican from OpenClipart, by molumen, Public Domain. More on Pelican, the bird.

Static site generators take your content, pour it into your templates and output the result as static pre-generated HTML, CSS, JS & image files. You can then just upload the resulting folder of output to your server and you’re done. All you need on the server is a web server of some sort, like Apache or Nginx - anything really - all it’s doing is serving static pages.

The huge advantage of this setup is simplicity:

  1. You can write your content in Markdown [1], reStructuredText [2] or AsciiDoc [3] - all simple text formats, designed to facilitate writing and get out of …
Continue reading “How I built this website, using Pelican: Part 1 - Setup”

Ever tried to copy something onto a USB flash drive, only to discover that the file was too big to copy?

This is because most USB Flash drives are formatted using the FAT32[1] filesystem - which only supports individual files up to 4 GB in size, no matter how much free space you’ve got. It also only supports drives up to 2 TB, can’t store symbolic links, can’t store files with these characters in the name: "*/:<>?\| – and is generally pretty crappy.

The solution is to use a better filesystem

There are many filesystems to choose from - but there are a few criteria that a good USB flash drive filesystem needs to meet which cut down the choices quite a bit:

  • Compatible with every computer - just plug it in, and it should work
  • Has no permissions, or optional …
Continue reading “Using UDF as an improved filesystem for USB Flash Drives”

I recently needed to convert some Apple Lossless music files to FLAC. Here’s how to do it:

If you don’t already have ffmpeg or libav-tools installed, do this:

$ sudo apt-get install libav-tools

Then run this to do the conversion, in the folder with music in:

$ for f in *.m4a; do avconv -i "$f" "${f%.m4a}.flac"; done

And that’s it - it will convert all the .m4a files in that folder to .flac files, preserving the metadata. You can now delete the .m4a files if you want:

$ rm ./*.m4a
Continue reading “How to convert Apple Lossless/ALAC/.m4a files to FLAC with avconv, on Ubuntu Linux”

Blueprint style diagram showing the compose key sequence for the Euro currency symbol.
Figure 1. Just hold down your chosen compose key, then press the other keys in turn: [compose key] + e + = gets you a Euro symbol.

The compose key on Linux is incredibly useful, but not configured by default - and on XFCE there’s currently no graphical UI to change it. However, it’s pretty simple to change…​ here’s how to make the Caps Lock key your compose key:

In the file /etc/default/keyboard, change XKBOPTIONS to look like this:

XKBOPTIONS="compose:caps"

Save the file. You can now either reboot, restart X, or see Activating your change without rebooting, below.

If you don’t want to use Caps Lock as your compose key, there are some other options to choose from in this file: /usr/share/X11/xkb/rules/xorg.lst - search for ‘compose’, they’re listed towards the …

Continue reading “How to set your Compose Key on XFCE/Xubuntu & LXDE Linux”

https://github.com/hdeshev/pelican-site-example/blob/master/blog/pelicanconf.py

def popular_articles(articles):
    populars = [article for article in articles if hasattr(article, 'popularity')]

    def comparator(x, y):
        if x.popularity != y.popularity:
            return -1 * cmp(x.popularity, y.popularity)
        else:
            return -1 * cmp(x.date, y.date)

    return sorted(populars, cmp=comparator)


def media_url(url, site_root):
    if re.match("^https?://", "https://yahoo.com", re.IGNORECASE):
        return url
    else:
        return "%s/%s" %(site_root, url)


JINJA_FILTERS = {
    "popular_articles": popular_articles,
    "media_url": media_url,
}
Continue reading “Adding Jinja Filters to Pelican”

I’ve been meaning to consolidate my personal websites onto this domain for a long, long time. My original personal website, dflock.co.uk, started in the late nineties - and has been getting a bit long in the tooth of late.

Screenshot of the current version of the dflock.co.uk website homepage
Figure 1. Static text files - the gift that keeps on giving.

That site has been up, looking mostly like that, for ~15 years - with zero maintenance or downtime. Nice to know it’s still valid CSS 1.0 :)

When I created that site originally, the options were either Adobe PageMill, or hand editing HTML in a text editor. I’ve never been a fan of WYSIWYG (what-you-see-is(supposedly)-what-you-get) editors - and the early ones were…​ not good, so I wrote all the HTML code by hand.

That site also has some data heavy pages, which are manually published from …

Continue reading “Welcome to the New Site; same as the Old Site.”

Discussion piece about Lock’s Law:

http://news.ycombinator.com/item?id=1895210

For a virtual environment to qualify as ‘a sandbox’, your users must be able to create turing machines, out of stuff the found lying around. - Locks Law (which I just made up :).

I wonder if it is possible to mathematically model what characteristics of an environment are relevant to be able to build an effectively Turing-complete mechanism?

All the ones that I’ve seen (minecraft, dwarf fortress, little big planet) are 100% mechanical, so I guess all you need is the ability to move things around, plus some kind of basic physics, so that moving things around can have knock-on effects. Most of the DF ones are fluidic computers (http://en.wikipedia.org/wiki/MONIAC_Computer) and the rest are mostly falling blocks style. Quite Pratchett-esque.

I …

Continue reading “Turing Complete Sandbox”