Sunday, 10 March 2013

New project 'Crayonizer' on Freecode

I just posted a new project, 'Crayonizer' onto Freecode. Crayonizer is a simple program that 'colors in' the output of other programs. You either use bash aliases or symbolic links so that crayonizer gets called when you run, say, gcc. It then runs gcc for real, and colors in the output. You can get it here. Here's a gratuitous screenshot:



With this project I've discovered that freecode will censor your release descriptions. For instance, I wrote:

"Will probably compile under OSX if the wind's blowing in the right direction"

but this appears on freecode as:

"May compile under OSX"

And the slogan:

"Console purtyfication for the people!"

is reduced to:

"Console purtyfication."

So I guess that brevity is still the soul of wit.


Thursday, 21 February 2013

Installing Another Operating System on Lenovo Think Centers

If you've recently bought a Lenovo Think Center, or any other PC that's "Windows 8 Enabled", you've likely discovered that you can't install your own choice of operating system (i.e. Linux) on it, it just keeps coming up "operating system not found".

This is because of a 'feature' called UEFI, which is basically a new form of bootloader that only very recent (as of Feb 2013) operating systems support. In order to boot from CD on recent PC's, you need to find the BIOS settings for this and turn it off.

On the Lenovo Think Center this setting is in 'Startup' and is called 'CSM'. Given that this is a vitally important setting to configure your PC, you'd think that a three-letter-acronym might not be the best choice for naming it. Better to name it something like "Enable Loading Legacy Operating systems" or "Disable Lenovo Useless Brick Mode". But no, it's just 'CSM' for 'Compatiblity Support Module'. You need to enable this in order to load your choice of operating system.

Another setting that might be relevant is under the 'Security' tab. This setting is 'Secure Boot'. You might need to disable this, or set it to 'setup mode' to allow installing of a new operating system.

Well, this is what worked for me. Hopefully this post will help others.

Thursday, 27 December 2012

I'm at Chaos Communications in Hamburg



I'm at the Chaos Communications Congress in Hamburg. There's not much to recognize me by, I'm just the guy dressed all in black (like that really narrows it down) who is using an ancient compaq laptop with bits missing off it, and who speaks no German.

Friday, 7 December 2012

Movgrab Popularity now 600

This week saw the release of version 1.1.14 of Movgrab, resulting in its 'Freecode/Freshmeat' popularity rating rising to over 600! Like all measures of popularity the freecode rating is... a number, that means... something. Maybe. Still, whether it's a meaningless figure of not, I still get a thrill out of watching it go higher.

This release adds support for files > 2GB on Gnu systems, adds support for downloading from Animehere, and fixes a problem with downloading 3gp files from youtube. All these changes/bugs were suggested or reported by movgrab users. Thanks to Karol Blazewicz, Deeice, Matthias B, Ndracs and others for taking the time to contact me, and thanks again to Abhisek Sanyal for his lifesaving patch to get youtube working again. Feedback from users is what will keep movgrab moving forwards!

My other projects languish with ratings well below 100. I've not had time to really work on them, and most of them are 'first releases' that have serious bugs. It's time for movgrab to take the back seat for a while I think, and for someone else to have some attention.

Wednesday, 14 November 2012

Movgrab Popularity Passes 500

I don't quite know what the 'Popularity' ratings on freshmeat/freecode really mean, but movgrab has passed a new level, reaching a score of 541. I think this means it's really quite popular. It's now included in a number of linux distros, and one 'extra programs pack' for the mac.

My other programs aren't getting anything like the same degree of love. I guess people don't need another FTP server, and Alaya, my dav aware webserver apparently still has too many bugs when run on other people's systems (hoping to solve those in a future release). Perhaps their time will come when they are more mature.

Tuesday, 10 July 2012

Got a Question? Just ask.

I'm seeing someone coming to this blog from the google queries:

movgrab commands size of file
movgrab record time


I get the impression that someone has some questions to ask about my 'movgrab' program. So, you can just ask me in the comments to this post, if you have!

Monday, 26 March 2012

Ready for my close up, Mr DeMille

I've been quiet on this blog recently, busy, you know how it is. But I've got to boast about this, someone has made a youtube video about my movie downloader program 'movgrab'.

It's at youtube: http://www.youtube.com/watch?v=R9YhoYay_Q4

Movgrab has been getting a lot of love recently, with people blogging about it all over the place. I've also had one or two feature requests that I'm going to try to implement sometime. But I must admit, I like the youtube vid best of all.


Wednesday, 21 December 2011

Movgrab Popularity at 400

Movgrab's freshmeat (they're changing their name to 'freecode' but you'd know them as freshmeat if you know them at all) popularity rating has passed the '400' mark. I would like to say that it's smashed through this barrier, but as it's just managed to struggle to 400.13, and will probably drop back below 400 soon, well, I can't really say that.

I've no idea what this number really means, but I think 400 means 'quite popular'. Movgrab is now included in a few linux distributions, like Puppy linux, Arch linux and maybe Debian (someone did contact me asking me to make a change to allow it to be included in the debian build process).

One person has even written a nice-looking frontend to movgrab, I think this frontend comes as part of puppy linux.



You wouldn't think it from the feedback I've had though, despite setting up an email account for people to contact me with bug reports etc, very, very few people have done so. If you're one of those who did (you know who you are) then thanks very much, some of the bug reports I got were things that I'd never have known about it people hadn't taken the time to report them.

Now it's time to get some other projects finished and uploaded!

Thursday, 10 November 2011

Using unix consolefonts in your programs

If you're running linux or another unix-style system, then you probably have a little-known directory in '/usr/share/consolefonts'.

This contains 'font files' that can be used with the 'setfont' command to change the default font at the linux console (not on xterm or rxvt or anything like that, at the actual 'text mode' console). If you're looking for how to do that, it's as simple as:

setfont drdos8x16
setfont cybercafe

where the 'name' of the font is it's filename without path or extensions (setfont knows to look in /usr/share/consolefonts).

This post is about how to decode these font-files for use in your own graphics programs.

These fonts have a very simple format, being little more than a collection of bitmaps (not .bmp format, but actual bitmaps, i.e. collections of bytes where every bit is a monocrhome 'pixel' that's on or off). If you're messing about with low-level graphics, they are an easy way of doing text.

There's 3 types of font in the console font directory.

1: Raw Fonts

These usually have the file extension '.fnt' (or .fnt.gz if gzipped). They contain an array of 8x16 bitmaps, or 'glyphs' of the characters in the font. The bitmaps are arranged so that they map to the ascii character set, so to find the bitmap for ascii character 'A' which has an ascii value of 65, you would just get the 65th bitmap in the array. As each character is 8x16, and so 16 lines of 8 bits, or 16 bytes, so you just calculate the position in the bitmap array as '<ascii value> * 16'.

Thus, the first byte of the file is the first 'line' of 8 pixels in the first character. For each bit that is set in those eight bytes, you should set or 'color' a pixel in an image, and leave blank those pixels that match to unset bits in the byte. The second byte is the second line of the character, and so on.

2: PSF Fonts

These are very similar to 'Raw' fonts, except they have a header. This header starts:

Byte 0: 0x36
Byte 1: 0x04
Byte 2: 'Mode' (256 characters or 512 characters)
Byte 3: Character Height

The first two bytes are just for identifiying the file type, and the 'Mode' byte says how many characters are stored in the font-file. If the first bit of this byte is set, then there are 512 characters, otherwise it's 256. The final header byte is the character height, allowing you to have glyphs that are 8x8, or 8x12 or 8x128, or whatever. Notice though, that for basic PSF fonts, the width of the character is still always 8 bits, or one byte.

After this 4-byte header the font is just the same as 'raw' fonts, except you have to consider that each glyph is as many bytes long as the 'Character Height' setting says.

3: PSF2 Fonts

The most advanced type of console font, it seems, are an extended version of 'PSF' fonts, called 'PSF2' fonts. These have an enhanced header:

Byte0: 0x72
Byte1: 0xb5
Byte2: 0x4a
Byte3: 0x86
unsigned int version;
unsigned int headersize; /* offset of bitmaps in file */
unsigned int flags;
unsigned int length; /* number of glyphs */
unsigned int charsize; /* number of bytes for each character */
unsigned int charheight;
unsigned int charwidth;

After the first 4 identifying bytes all the information is unsigned 4-byte integers. Everything does pretty much what it says. As now both the character width and character height can change, so you can no-longer calculate glyph positions in the file with 'lines * NoOfLines', but you can use the helpful 'charsize' value. Thus the glyph bitmap for a given character is found at 'headersize + <ascii value> * charsize'. 'length' tells you how many characters are in the file, and 'charwidth' now means you have to consider that each line of a character might use less than one byte, or stray across two or more bytes. However, the bitmap data is padded to a byte boundary, so if a font has a width of '12', or 'a byte and a half' it will still use 2 bytes for every line in every character.

Some of the default fonts distributed with the linux 'kbd' package (arm8.fnt, cybercafe.fnt) look surprisingly good when used on charts and the like, and they're about the easiest font-type to use in your own programs without turning to libraries like 'Freetype'.

Wednesday, 9 November 2011

Howto use Picasa API with Blogger API




When you use the blogger api, the pages you get back contain a type of tag called 'gd:extendedProperty'. These contain some useful data.

Just do an http get to: <blogurl>/feeds/posts/default

So, for this blog you are reading: http://idratherhack.blogspot.com/feeds/posts/default

This will return a big mess o' xml, including the tags:

<gd:extendedProperty name='IS_PUBLIC_BLOG' value='true'/>
<gd:extendedProperty name='PICASAWEB_ALBUM_ID' value='5570923802870618657'/>

It turns out that one of these (PICASAWEB_ALBUM_ID) is a link to the Picasa album that is used by your blog.

You can use this link to upload pictures using the picasa api documented here http://code.google.com/apis/picasaweb/docs/2.0/developers_guide_protocol.html.

When you do the upload you'll get back another mess-o-html which will include a tag called 'content'. This should give you the 'web visible' link for the image, which you can now use in posts to your blog.