Monthly Archives: July 2006

no pop today

Bronwyn went into labour at 11:30pm last night.

She is still in labour. We’re about to go to bed, but I thought I’d share my experiences of a home birth so far.

When Jareth was born, we spent three days in Cavan Hospital. That’s “Cavan”, not “Monaghan”, because Monaghan hospital is not allowed to do births.

Those were probably the most uncomfortable three days we have ever had. I slept in the waiting room on the first night, and was only told about the “guest bedrooms” the second night.

I was asked if I would not rather go home for the night and come back in the following morning. No, I wouldn’d like that – from Monaghan to Cavan is a round trip of about 120km – not an easy trip for someone who doesn’t drive.

Bronwyn had a particularly awful experience of it. One problem with hospitals is the whole conveyor belt system of it – there is no cameraderie between the doctors and patients. There is the distinct impression felt that patients are problems to be solved, instead of people to be helped.

Bronwyn has a mild phobia of hospitals. This is not helped by the doctors never explaining what they’re doing, or sticking around to talk and find out how she’s feeling (get your eyes off the chart and ask).

My boss, John, dropped in to see us at lunch time. Bronwyn was sitting down to a huge plate of curry. He was remarking on how amazingly relaxed we both were. This was unsurpising, though, when you consider it – Bronwyn’s not being treated as an object, and is not being poked and prodded without so much as a by-your-leave.

In Cavan, she was physically examined at least five times in the few hours before the gynaecologist broke her waters. This was a very uncomfortable experience for her, which was thankfully avoided here – Bronwyn’s midwife, Susan, is very sensitive to her needs and wants, and is not as bound by conservative procedure as hospitals are.

Anyway… it’s 10:40 here, and we’re going to bed. Maybe tomorrow will be the day… I certainly hope it’s not 3am in the morning, though – I need my beauty sleep!

online crossword maker

Lately, I’ve been working my way through a book of cryptic crosswords.

On the way to work, I amused myself by thinking up some clues myself.

When I got here, I thought I’d look up some software to try making my own crossword. here’s the first one I found, and here’s a small example of what it can do (with the horrid HTML cleaned up):

1       2  
3          
           
           
           
ACROSS

3. south american flower in a book shop

DOWN

1. confused 5 nearly left the quoted bird
2. water a heavy microchip

The HTML leaves a lot to be desired, but it’s pretty good for a first find. I think I might write my own crossword (and crossword-makeer) later today.

See if you can solve that simple one. First correct answer gets a clap on the back.

two konqueror js workarounds

In the evenings, I work on my KFM project – an ajax file manager. One of the current challenges is getting it to work in Konqueror.

I managed to overcome two head-wreckers yesterday – broken support for oncontextmenu, and no support for window.getSelection().removeAllRanges().

clearing the selected range

I’ll explain the latter first, as it was surprisingly simple in the end.

click here, then drag from the bottom right of the files area to the top left. note that the resulting rectangle surrounds some text, but the text is not selected (ie; not highlighted). That is the required result.

To do that in IE and Firefox, you simply empty the selection upon mousemove. For Firefox, that’s window.getSelection().removeAllRanges(), and for IE, that’s document.selection.empty();.

There is no equivalent for Konqueror, so I needed to wrack my brains to come up with a workaround.

In the end, it was bloody simple – when the dragging starts, create a transparent layer which floats above everything, and covers the entire window! That way, you simply cannot select anything if you want! When the drag is completed, simply remove the layer and carry on as normal.

contextmenu

This was a bit harder to workaround, but only because I couldn’t find any documentation that explained why it wasn’t working as expected.

The usual way to open a contextmenu is to attach an oncontextmenu event trigger to an element, then when it is triggered, you cancel the window’s default behaviour with e.preventDefault(), where e is the event (e.returnValue=false in IE).

Unfortunately, tests showed that in the case of Konqueror, oncontextmenu triggered the default behaviour before the script could prevent it.

I had to sit back and really think about this.

What is oncontextmenu? It is a trigger which activates when the right mouse button is clicked.

Upon onmouseup, the default behaviour rudely intrudes, so we need to use onmousedown instead, and cancel the default behaviour.

Now, I hate to write code that forks, so I tend to keep browser-specific code in completely separate files, where those browsers can override the correct functions with their own shoddy hacks. For example, on the KFM project, here is the main code, here are the IE-specific functions, and here are the Konqueror-specific functions.

Note the browser-specific versions of addEvent().

Correct (Firefox):

function addEvent(o,t,f) {
	o.addEventListener(t,f,false);
}

Internet Explorer:

function addEvent(o,t,f) {
	o['e'+t+f]=f;
	o[t+f]=function(){o['e'+t+f](window.event);}
	o.attachEvent('on'+t,o[t+f]);
}

Konqueror:

function addEvent(o,e,f){
	switch(e){
		case 'click':{
			f=(function(f){return function(e){if(e.button==1)f(e)}})(f);
			break;
		}
		case 'contextmenu':{
			e='mousedown';
			f=(function(f){return function(e){if(e.button==2){e.preventDefault();f(e)}}})(f);
			break;
		}
	}
	o.addEventListener(e,f,false);
}

There y’are. Took me hours to think those up. You get them for nothing.

kfm 0.4 – multilingual

more details

New Features

  • panels may be turned off
  • various panel actions (move, resize, etc)
  • long file names are automagically shortened
  • new panels – “file properties” and “directory properties”
  • KFM is now themeable
  • KFM is no multilingual
  • various improvements to the code
  • various bug-fixes

The biggest feature in the above is the Multilingual ability.

Extreme thanks go out to Janich Rasmussen, who provided the Danish translation (demo), and wendwerfer (Thomas ?), who provided the German translation (demo) (and kickstarted the multilingual code by providing his languagepack!).

commented blocks of code

I was reading an article about maintainable JavaScript, and thought I’d comment on it about a method I use to keep my own JavaScript clean.

Although this is about JavaScript, the exact same trick works in PHP as well.

A method I use for commenting also helps me to create navigable code. I use vim for coding, which allows me to “fold” at the ‘{‘ mark, making blocks and functions into hierarchical trees.

A useful thing about this, is that you can then place your comment after the ‘{‘.

screenshot.png

For example, check out this code.

Scattered throughout the code, you can find blocks starting with “{ //“.

A handy thing about the {..} syntax, is that it doesn’t actually need to follow an if/function()/for() qualifier! This means that you can logically separate your code into blocks of contextually similar code.

kdevelop and other IDEs also allow you to fold at the'{‘ mark.

video demo of kfm selections

I was reading through blogs yesterday, and came across a post by Gilles Caulier describing Wink – a Tutorial and Presentation video creator.

Had to give it a go, so during my lunch hour, I whipped up a video demoing some selection methods in KFM.

th3 l0rdz pr4y3r

As prayed by Balor on #linux:

11:29 < balor> Will the priest appreciate this: Our Father, who 0wnz heaven, j00 r0ck!
11:29 < balor> May all 0ur base someday be belong to you!
11:29 < balor> May j00 0wn earth just like j00 0wn heaven.
11:29 < balor> Give us this day our warez, mp3z, and pr0n through a phat pipe.
11:29 < balor> And cut us some slack when we act like n00b lamerz, just as we teach
11:29 < balor> n00bz when they act lame on us.
11:29 < balor> Please don’t give us root access on some poor d00d’z box when we’re
11:29 < balor> too pissed off to think about what’s right and wrong, and if you could
11:29 < balor> keep the fbi off our backs, we’d appreciate it.
11:29 < balor> For j00 0wn r00t on all our b0x3s 4ever and ever, 4m3n.

adjusting filenames for icons

Last night, after a bit of discussion in the KFM bug tracker, I spent an hour or two coming up with an algorithm to shrink the centre of a filename so that the text did not cause its icon to stretch (demo).

before:

after:

I think the result is very clear, and the red ‘[…]‘ pretty obviously means that something is spliced out.

How it works

The icon is set to overflow-x:hidden and has a specified width. We get the value of that width, then reset the width to “auto”.

If its new rendered width is now less than the original, then the filename was fine – replace the width and go onto the next icon.

Otherwise, get the extension and the … part-of-the-filename-which-is-not-the-extension … hmm … pre-extension?

Go through a do...while loop which gradually removes the last character of the pre-extension, replaces the icon’s text with pre-extension+'[…]’+extension, and tests to see if that changes the width to within the allowed parameters.

Once the do...while loop has run its course, the icon’s width is then reset, and its title is changed to the original filename (see the tooltip in the above).

Tada!

For more coolness, please check out the KFM site.

KFM website created

A lot of discussion was had today about open source projects, both on the ILUG mailing list, and the #linux IRC channel.

I concentrated mostly on the questions that centred around my KFM project. Kevin Lyda had a lot of very good input.

KFM, at the moment, is open source. I have written it completely in my spare time, and, while my company has a certain claim over code that I write on this computer (which they provided to me), using this broadband connection (which they pay for), they are happy to let me have my fun for at least a few months, before we decide to use the KFM for an in-house project, at which time, I will probably not have the time to work on it externally as well.

So, in light of that, I am calling on all web developers out there to start using it NOW. Use it, comment on it, help to debug and improve it.

The more that the KFM is developed by other people, the more apparent it will become that, in order for the project to retain absolute top quality, it should remain open source.

After all, I am only one person, and I tend not to notice minor bugs if I can work around them! The project needs a lot of people looking at it. After all, “given enough eyeballs, all bugs are shallow”.

So, without further ado, I present kfm.verens.com.

kfm 0.2 for FCKeditor

Here’s the announcement I made on sourceforge and my bugtracker

I've put a little time into making this work with IE, so it's time
to throw it out to the wolves, to see if it survives.

Improvements:
 - multiple-selection using dragging
 - files may be used for FCKeditor by hitting the Enter key
 - drag-and-drop moving of files to directories
 - multiple file deletion
 - deletion using the Delete key
 - directory deletion
 - image resizing
 - image caption editing
 - shift-click multiple selection
 - contextmenu adapts based on single or multiple file selection
 - log of actions
 - file upload button only shows when needed.

An example of an FCKeditor with the KFM as a file browser:
http://demo.verens.com/fckeditor/2.3/_samples/default.html

The plugin itself:
http://demo.verens.com/fckeditor/2.3/editor/plugins/kfm-0.2.tbz2