beatworm.co.uk

There is a top level navigation menu at the foot of the page

ANS: Once upon a time, Apple used to ship some fairly funky, fairly chunky AIX boxes.

2014-04-02 by cms in computers, history, links

Serapeum: is a conservative library of Common Lisp utilities. It is a supplement, not a competitor, to Alexandria.

2014-03-31 by cms in computers, links, programming

Bup: A highly efficient file backup system based on the git packfile format

2014-03-30 by cms in computers, links

2013 ioccc winner – Largest Small System Emulator: I am delighted by this.

2014-01-11 by cms in computers, history, links

Elisp lexical closures are readable forms: Lexical scoping for emacs lisp means doing some unlearning.

2014-01-01 by cms in computers, links, programming

Useless bullshit: jwz doesn’t want to scrobble.

2013-12-07 by cms in computers, internet, last.fm, links, music

19 Years of OPENSTEP: OMG I’m old.

2013-11-01 by cms in computers, history, links

Comic cover screensaver

I've been using a set of superman covers I scraped from Superdickery.com as a screensaver on my Mac for a couple of years. I just dropped them all in a folder, and pointed the built in "slideshow" saver at it. Set to "Shifting Tiles" with 'shuffle slide order' it makes a nice regular grid of comic books that zip in and out regularly.

Last week I had a notion. I dusted off my old Canon LiDE A4 USB scanner, fired up VUEScan and set about scanning a couple of boxes of my own comic book collection. It was a suprisingly therapeutic couple of hours mechanical work to scan a few hundred, and the result is a more pleasingly personalised slideshow, with a larger number of member images. 

After running with it for a couple of days, I'm really pleased with the results. It could do with a little more variety, because I scanned from boxes where the material was alphabetically organised by titles (what am I, some kind of nerd?). Some other observations – the 90s were really dark, both in the stupid post-Watchmen 'gritty heroism' sense, but also more literally in the colour palettes. This is really obvious contrasted against the four poster colour silliness of the classic Super titles I've switched from. Ironic that high grade reproduction technology and digital colouring options, as well as the shift to fully painted illustrations seems to have lead to a more muted spectrum of offerings. Perhaps this says a little about my youthful tastes. Also, what was I thinking sticking with that second run of 'Mage' ("The Hero Defined"). That book was pretty terrible as I recall, and I've certainly got no urge to reread and check my assumptions. I'm leaving them in the set, because it seems dishonest not to. 

I've got another dozen or so boxes to scan. I should do some sums to work out what the storage implications of that represents before I commit to bunging the rest of them on my 256GB SSD though. 

As a side thought, I realised that everpix had diligently uploaded all my scan jpgs, so I can present a public gallery of the work so far for your bemusement.

posted Saturday, October 26, 2013 at 12:00 by cms in art, comics, computers | No Comments »

Album Shuffle: I published my playlist generating python tool onto github

2013-04-25 by cms in computers, links, programming

Cool Shell Prompts

If you have a Mac, and you use Terminal.app to run UNIX commands, try executing this for a cool shell prompt

export PS1="\360\237\220\232 $ "

See what I did there?

If you are using a UTF-8 encoding for your terminal, which you probably are, and if you're using a recent OS X, and have the right fonts installed, which you probably do, you should have a little sea-shell graphic for your prompt. Literally a cool shell prompt.

Screen Shot 2013 04 09 at 19 11 42

In a recent revision to Unicode, code points were assigned for many emoji. Emoji-what-now? These are little emoticon glyphs that rose to popularity in Japan. Apple have included a nice typeface with full colour icons for a subset of these in the last couple of releases of both iOS and OS X, so you can use them in most applications that use the system type rendering library, like Messages. On OS X, this includes the bundled Terminal.app terminal emulator. So you can print little icons in your shell, if you know an encoding for a particular glyph.

Here's the ever popular 'pile of poo' ( U+1F4A9

Screen Shot 2013 04 09 at 20 09 46

 

Not sure what that is supposed to be used for, but it's terribly popular on the internet. "But how", I hear you ask, "do you find out the encoding sequences for these appealing novelties?"

Well, you can search for unicode code tables on the internet. On the Mac though, the easiest thing to do is probably to enable the Character Viewer tool via the Language and Text System preference pane. 

Screen Shot 2013 04 09 at 20 19 23

This gets you a panel like this, where you can browse all the characters your computer knows how to render, including all the emoji sets, and find out their Unicode code points, and more importantly, a way to encode that code point in UTF-8.

Character viewer copy 

So, as you can see in my fecal example, the UTF-8 byte sequence for 'pile of poo' ( U+1F4A9 ) is F0 9F 92 A9, and we can print that in a bash shell, using echo with the -e flag to enable interpreting of escape sequences, using the \x escape prefix to indicate bytes in hex. 

Going back to the original shell trick, the shell emoji ( U+1F41A ) has the UTF-8 encoding F0 9F 90 9A. The bash shell doesn't seem to have an escape sequence for hex encoded bytes in it's prompt string, but it does interpret 3 digit codes prefixed with a plain \ as octal encoded literal bytes, so if we convert this hex string to four octal numbers, using bc or od, or emacs or just Calulator.app, we get the escape sequence from my initial shell example – "\360\237\220\232"

So far so cute. But is there anything vaguely useful you can do with this sort of thing? Sort of. A picture's worth a thousand words. So we could perhaps encode mnemonic information in icons, and somehow dynamically update the prompt to reflect this.

Bash will execute the contents of an environment variable PROMPT_COMMAND as a shell command immediately before the shell prompt is printed. Typically this is used to update terminal colours or title strings with escape sequences, or update PS1 to add some content that can't be printed using the built-in prompt escape functions. I decided to make my prompt respond to the result of my most recent command.

Here's the relevant shell glue I just stuck in my .bashrc 


emoji () {
if [ $1 -eq 0 ]
then
echo "\360\237\230\203 $ "
elif [ $1 -gt 0 ]
then
echo "\360\237\230\225 $ "
fi
}
export PROMPT_COMMAND='PS1=$(emoji $?)'

This runs a shell function called emoji in a subshell, which returns a string based on the input argument. The input argument I'm using is the exit status of the last shell command. This gets me a smiley face in my shell prompt, unless the last command I ran returned a non-zero exit state, which in UNIX, indicates a problem happened. This makes my prompt draw as a 'confused smiley', if something has gone wrong.

Screen Shot 2013 04 09 at 20 41 56

Still cute, and almost useful!

I think I'll keep it for a while.

 

posted Tuesday, April 9, 2013 at 19:47 by cms in computers, programming | Comments Off