Almost a Blog

Month: August, 2004

Web Standards CSS and HTML

Before I start I just need to say that I am an advocate of standards but I am not a religious bigot about them.
My problem has never been the technicalities of CSS or HTML, lets face it if you have figured out Perl to a reasonable degree and know your way around half a dozen programming languages then adding some markup etc to your toolbox is hardly going to kill you. Or at least you wouldn’t think so?
Unlike programming languages and their platform specific problems, browsers display your work as they see fit. The user at the other end may see a work of art or a bloody debauchery and judge you and your ability accordingly.
The browser doesn’t even have the common decency to open a window informing the user that it’s made some complete horlicks in rendering our page, nor should it! It’s our problem! if we want people to read the stuff the least we can do is make it as legible as possible for them, its not their fault the browser has a few quirks.
The internet, for all intents and purposes is a new method of communication and like all previous methods of communication it comes with its fair share of problems ie its new, its evolving, it hasn’t reached any form of maturity yet. As an analogy:
Have you ever phoned someone and had a “BAD LINE”. This prompts you into very articulated speech were all the words are formed “just so” and you might even talk a bit louder. Mean while, in the back of your mind you are cursing the weather or your blaming the old exchange down the road for the bad reception.
Without even realising it you will be compensating for the deficiencies of the system you are using with your loud speech and long drawn out words. You might not like it but its an accepted part of the system and out of your control so you just get on with it and do your best. Web Development (Development in general) is like this.
I am all up for standards but I am not one to take a pop at something because it has not been done “Just So”. Implementing standards is a process and there is no need get all religious about it.

Fun With the Gimp

I have been meaning to learn some sort of image manipulation tool for quite some time. I have used the Gimp in the past when I want to scale something or convert images from one format to another but I have never had the time or inclination to sit down and learn enough of it to be reasonably confident.
I have just had a long weekend so I decided to learn it because like it or lump it, its a very handy tool in any web developers arsenal. I mainly do backend work but there are occasions when I envy the versatility of other web developers when putting together sites. If you want to have a look at the sort of stuff I mean have a look at the The Zen Garden. Some of the pages on that site are just divine.

A Mathematician’s Apology

I started reading
A Mathematician’s Apology
Author: G. H. Hardy (Foreward by C. P. Snow)
ISBN: 052142706
this one as soon as it arrived through the post. It is quite a small book and even smaller when you open the cover, at least in this edition it is since they have left over an inch of margin around the text.
I really enjoyed it. I have to say that I enjoyed the forward by Mr Snow as much as the content by Hardy. I think this was because he was writing about the Author of whom I would like to know more whereas Hardy was writing about his subject rather than himself. You can get a feel for Hardy’s character from the text, particularly near the end but I thought that it dealt mainly about his take on mathematics.
The book is definitely some sort of apology, I thinks its open for debate whether he needed to apologize for anything but he obviously felt the need to justify himself in some way.
Personally I don’t think Hardy had any more need to justify himself than Da Vinci, Matisse or Michelangelo, Hardy was an artist its just that his art was mathematics which like some forms of art is not appreciated by the masses. However, this does not mean that what he created wasn’t beautiful or worthwhile. In fact years later it was found that a lot of what Hardy had created was of immense use.

Sans Serif or not to Sans Serif

I am pretty damned sure that fonts are one of the most used yet least appreciated aspects of computing I have come across.
It would be fine to interject here and say NO, surely its “blah de blah”. I say no…… People in general don’t give a damn about how machines work / talk / do their stuff, however they are concerned with how stuff looks.
For instance, look at the fashion industry. Clothes are expensive but the workmanship is generally crap but who cares, its a “scurgly! made by whatsisname”, and it looks good.
Its the same with computers, look at the Mac, previously thought the underdog, now its almost a fashion statement to own one.
Anyway, back to fonts. I am not really that bothered about what fonts are on my machine as long as I can read the text without squinting to much, but just the other day it was noted that I was using “Sans Serif” fonts and I was lacking in “Serif” fonts.
Well… I just shit my pants, what the hell was I missing. Apparently I wasn’t missing anything. Sans Serif add an extra bit to your fonts and I was missing the option of not missing them on everything I read.
To cut a long story short I needed to get some Microsoft fonts installed on my Debian box and this is the process.
First thing I needed was the Microsoft truetype fonts. ON debian these are called
and can be installed via “aptitude” or apt whichever you prefer. I fetched these and this installed a whole pile of stuff in
Next thing I needed to do is create a “fonts.scale” file as ROOT
]$ cd /usr/share/fonts/truetype ; ttmkfdir;
sorted. The directory should now have the correct file. The next thing to do is restart either, the font server, or X11. I just logged in and out and that was it. New fancy fonts that are almost identical to the ones I had previously or at least in first inspection they are.

More bloody Books

I am never going to finish “From Here to Infinity”. I was about half way through Mr Stewarts book when I got an urge to browse Amazon, big mistake.
I spotted the following books all of which I ordered
A concise History of Mathematics.
Author: Dirk J. Struik
A Mathematician’s Apology
Author: G. H. Hardy (Forward by C. P. Snow)
The Man Who Loved Only Numbers
Author: Paul Hoffman
A History Of Mathematics (An Introduction)
Author: Victor J. Katz

Remapping Keys in Linux

I never really had to do this before but I have been using enlightenment for a few months now and use the ALT-(q,w,e,a,s,d,z,x,c) to switch between 9 separate desktops. I find this quite quick but I tried xemacs the other day and I needed ALT-x but I kept switching between desktops. So I decided to use a different key.
Since the Windows key ie the one to the left of the left ALT button is never used I decided to use it to switch desktops instead (I know I will need to use the ALT key in other applications so I might as well do it now before its ingrained into me).
Anyway the procedure goes as follows.
1. Detect the keycode of the key you want changed.
Open a terminal and type
]$ xev
Lots of text should whizz past on the terminal and then stop. Touch the key you want the keycode of and more text should whizz past…. something like
KeyRelease event, serial 25, synthetic NO, window 0xe00001,
root 0x38, subw 0x0, time 24436498, (-298,301), root:(458,320),
state 0x0, keycode 115 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes: “”
We can see that the keycode is 115.
2. Create a user modmap file to be loaded on starting X
]$ cd ~; touch .Xmodmap
and put the following text in it
keycode 115 = Hyper_L
add mod3 = Hyper_L
then edit your ~/.xsession file: Add
xmodmap .Xmodmap
before the “exec enlightenment” line and that should be you sorted. If for some reason you did not have a .xsession file then you will need to add the line to start whatever window manager you are using ie in my case my .xsession looks like
xmodmap .Xmodmap &
exec enlightenment
yours might well be
xmodmap .Xmodmap &
exec sawfish
You should now be able to use the MOD3 modifying key in e16keyedit as a modifier key after restarting xwindows.

Vim Folding and Perl

I decided to get function folding working today and discovered that it is relatively simple to set up unless Vim isn’t detecting your filetype correctly which it wasn’t in my case.
To get basic Folding for Perl working add
let perl_fold=1
let perl_fold_blocks = 1
to your .vimrc file and then open a .pl file and you should see lots of blue lines running across the screen. These are where the folds have been made and you should see a line count similar to
+– 24 lines: sub summit_sub {——————————–
Put the cursor on this line and press “za”. This will magically unfold the line. Pressing “za” again refolds the line.
I don’t like the perl folding defaults so I dedcided to run with the manual ones but my filetype was alway wrong when working on a modules. it was inserting c-style foldmarker ie “/*}}}*/” instead of the perl foldmarker #}}}
This was easlily remedied as follows
au BufRead,BufNewFile *.pm set filetype=perl || set commentstring=#%s
I now have folding working. Now all I need to do is decide what type of folding I prefer.

PDF Tool

I was asked the other day if there was an easy way in Perl to join two pdf files together. The answer is that there is an easy way. It might not suit everyone but I managed to find a tool called the pdf toolkit (pdftk). Its another of those handy tools that gets filed in the magic toolbox for later retrieval.

Vim regex

I was wanting to start some comments in a large Perl module the other day and not really had to use Vim’s regexp to any great degree because I know Perl I decided to see if it could be done.
I decided to add a little bit of pod above every funcion. The following was the result Remember In vim the ^M is a control character for carriage return and can be achieved by holding down the control key and pressing carriage return.
The following regex
:%s/^sub\(.*\) {\(.*$\)/=head \1\(\)^M^MDescrition:^M^M=cut^Msub \1{\2/
sub summit_sub {
=head summit_sub()
sub summit_sub{
The following regex
:%s/^sub\(.*\)\n{\(.*$\)/=head \1\(\)^M^MDescrition:^M^M=cut^Msub \1{\2/
sub summit_sub
=head summit_sub ()
sub summit_sub {