JS1k: Moth Goo2013-04-01

My js1k entry has been accepted! You can find it at js1k.com here.

Note that a bug causes the game to fail loading, so you may have to reload the page after clicking the above link. Irritating bug, i know.

I have had great fun making this entry to the spring competition and it has been amazing to see how much that can be done in 1024 bytes of Javascript. Do take a look at the demos. There are some truly awe inspiring examples and creative ideas.

In terms of fun the JS1k competition owes a lot to the world of byte saving techniques and tools that are being built to automate this such as jscrush or crunchme.

Also the Canvas element is really amazing. MDN has some good canvas docs.

Custom git log2012-12-18

The most interesting tools I have used to examine the git log include tig for use in the terminal, gitk which gives a very nice graphical overview and the fugitive plugin for using git from vim.

Despite all these nice tools I often use the git log command in the terminal because it is quick and easily to type. I have used this git log alias in my ~/.gitconfig quite a lot:

[alias]
lg = log  --graph --decorate --date-order --pretty=oneline --date=local --abbrev-commit --all

I wanted to improve on this and lo! this script was created:

gitShortLog() {
    local ymd=$(date +%F)
    local ym=$(date +%Y-%m)
    local y=$(date +%Y)
    local f="%w($(($COLUMNS - 4)), 0, 9)%C(cyan)%ad %C(magenta)%aE%Cgreen%d %Creset%s"
    git log --graph --date-order --date=iso --abbrev-commit --color --all \
            --pretty=format:"$f" $@ \
            | sed -e 's/ [+-][0-9][0-9][0-9][0-9] / /' \
                  -e 's/@[a-z0-9_.\-]\+//i' \
                  -e "s/${ymd} \\|${ym}-\\|${y}-//" | less
}
alias gl='gitShortLog'

This script includes the date and time of a commit, the user that created the commit and a short status message. Some superfluous information is removed, i.e. the time offset (+0100), the domain of the committer (assuming that the username part of email addresses is unique, which it often is) and the part of the date that corresponds to the current moment (i.e. only 10-11 is displayed if the commit date is 2012-10-11 and the current year is 2012).

Using a shell function The instead of a git log alias allows use of the $COLUMNS variable to calculate where to break lines. The %w() format option takes care of that. Subtracting 4 from $COLUMNS made the output a bit nicer to look at.

The three invocations of the date command could probably be avoided by making the sed regex a bit nicer,...

Line Length Vim plugin2012-12-04

Released the line_length vim plugin which lets you set a maximum line length. Lines that are longer than this maximum will have the overflowing parts marked with a custom background color.

Bladre.dk2012-12-01

For a long time I have not updated this site, but now is the time to revive some of the content that could once be found here... ☺