luatz 0.2 Release

I’m happy to announce a new release of luatz: 0.2

My lua library to work with dates and times.

Features include:
  • A os.date compatible class “timetable” supporting normalisation
  • Conversion between locations (time zones) using your local zoneinfo database.
  • RFC-3339 parsing
  • Works with 5.1, 5.2 and LuaJIT.
New in this release:
  • Support for fractional timetable component normalisation
    • e.g. .month=6.5, .day=1 (which could be read as “the first day after the middle of June”) normalises to .month=2, .day=16
  • Top level aliases for common operations
  • Own implementation of stftime formatting (locales are not yet complete)
  • Uses ljsyscall for more accurate time when available
Currently hosted on github (along with documentation and examples): https://github.com/daurnimator/luatz
Available via MoonRocks: https://rocks.moonscript.org/modules/daurnimator/luatz/0.2-1
Source download: https://github.com/daurnimator/luatz/releases/tag/v0.2
Systemd bindings for Lua

Today I took a dive into systemd, trying to learn how it works, and what features it provides.

As I played around with unit files and creating my own services, I started wanting to do it all via lua. So I spent the morning writing some C bindings to libsystemd.

The fruits of this labour can be tracked over at github and downloaded from moonrocks

Assembling a new home

I recently moved to New York, leaving most of my belongings back in Australia, since many people keep asking me about where I bought things, I thought I should make a list of the products that I’d buy again…

From Amazon (including gratuitous use of affiliate links)

Shipping from amazon is fast and usually well packed; this is not true for furniture though, and I strongly advise purchasing anything over 20kg elsewhere, the dining table had to be delivered three times before I got one that hadn’t been damaged in shipping.

From Totally Furniture

Arrived very quickly for such a massive item, cannot fault the freight company they used.

From Walmart (Online)

Quite a hefty list; it takes a lot to fill an apartment…..
Many items didn’t make the list due to falling apart after only days, or arriving damaged.

Hopefully someone might find this post useful.
Made myself a nice new bash prompt using lua. Code can be found in this gist.
I started off trying to set PS1, but bash will incorrectly calcuate the prompt length. This leaves you with strange line wrapping behaviour. Thanks to Rob Hoelz I found out about PROMPT_COMMAND, which allows you to run a command before PS1 is printed.
I used ljsyscall to avoid as many new processes as possible, they could be replaced by commands if you want.
To get the git and mercurial (hg) status, I had to call out to see if the current directory is inside a repository: this can sometimes be slow, as git and hg have to traverse the whole way up the directory tree stat-ing for .git and .hg folders.
EDIT: Using PROMPT_COMMAND caused issues when scrolling through history, or pressing backspace at the beginning of a line. From the #bash IRC channel I found out that you can inform bash of non-printing characters by wrapping the bytes in \1 and \2. The gist has been updated.

Made myself a nice new bash prompt using lua. Code can be found in this gist.

I started off trying to set PS1, but bash will incorrectly calcuate the prompt length. This leaves you with strange line wrapping behaviour. Thanks to Rob Hoelz I found out about PROMPT_COMMAND, which allows you to run a command before PS1 is printed.

I used ljsyscall to avoid as many new processes as possible, they could be replaced by commands if you want.

To get the git and mercurial (hg) status, I had to call out to see if the current directory is inside a repository: this can sometimes be slow, as git and hg have to traverse the whole way up the directory tree stat-ing for .git and .hg folders.

EDIT: Using PROMPT_COMMAND caused issues when scrolling through history, or pressing backspace at the beginning of a line. From the #bash IRC channel I found out that you can inform bash of non-printing characters by wrapping the bytes in \1 and \2. The gist has been updated.

Document your ABIs!

Most of the time when programming in C, your API IS your ABI; but there are various cases where use of a pre-processor will break this symmetry.

I should be able to interface with your library without running a pre-processor over the headers first.

Getting FFmpeg on windows

All the guides to getting ffmpeg working on windows seem to be extremely outdated; so here is a quick howto:

  1. Download mingw
  2. Install mingw with MSYS option; it will download and setup in C:\MinGW
  3. Get the mingw coreutils extra package (can be found from here); current version
  4. Install the coreutils extras package by un-7zipping and un-tarring it to C:\MinGW\msys\1.0\bin
  5. Download yasm; save it as C:\MinGW\msys\1.0\bin\yasm.exe
  6. Download and extract ffmpeg source (I used revision 647ec6f)
  7. Edit your C:\MinGW\msys\1.0\etc\fstab file to add the location of your ffmpeg source
  8. Open MinGW shell (it should be in your start menu)
  9. change to the directory you extract ffmpeg (going via the alias you added in fstab)
  10. ./configure
  11. make