ie7 fix

For those of you that read my previous post mentioning how IE7 may be used to emulate the ^= selector in CSS, here is what needs to be done.

Download a copy of IE7 and unzip it. Overwrite /ie7/ie7-css3.js with /ie7/src/ie7-css3.js. Edit /ie7/ie7-css3.js and change:

attributeTests["^="] = function(attribute, value) {
	return "/^" + unquote(value) + "/.test(" + attribute + ")";


attributeTests["^="] = function(attribute, value) {
	return "/^" + unquote(value) + "/.test(" + attribute + ")";

It may be safe (although less readable) to change it to the following instead, if you wish:

attributeTests["^="] = function(attribute, value) {
	return "/^" + unquote( value.replace(/\//g,'\/') ) + "/.test(" + attribute + ")";

The reason for the above changes is that the return line returns a regexp which the script uses to determine a match. Unfortunately, that regexp breaks if an un-escaped ‘/’ is entered. The above code escapes all forward-slashes.

css tricks

I was looking for a hack to apply a CSS style to just a Mac version of a certain broken browser, and noticed something subtle: The external link to the W3 validator on the site has an interesting little image beside it. I wondered if the author had made a class for it which he painstakingly added to each external image, but saw no sign of it in the source. With a bit of searching, I found this rule in the CSS:

a[href^="http://"] {
   background: url(../img/external.png) center right no-repeat;
   padding-right: 13px;

That’s a very handy usage of CSS3’s attribute prefix selector.

It’s a pity that it doesn’t work in IE, but that can be fixed by using Dean Edwards’ IE7 patch.

Here is the CSS I use to emulate that effect:

#main a[href^="http://"]{background:url(/i/external.png) center right no-repeat;padding-right:13px;white-space:nowrap}
#main a[href^=""]{background:none;padding-right:0}

I have two lines because my blog uses absolute URLs, and it’s easier to fix this with a hack than to dig through mountains of code 🙂

The white-space:nowrap bit ensures that links do not word-wrap, thus providing interesting CSS breakages where the image appears halfway through the link (thanks Noirin for pointing that out!). Unfortunately, this breaks the image trick for IE6 in cases where the word-wrap would have taken place, but it’s better than the ugly confusion that would otherwise have appeared.

what is depression?

After telling people in work that I’ve been diagnosed as depressed, I got some weird reactions. One person acted like it was the end of the world for me and asked what the company could do for me. I replied that I’ve felt like this for about 10 years, so there’s no point acting any different to me just because the root of my attitude problems has been identified.

After writing the above paragraph, I think I’ve figured out the point at which it started! I “lost interest” in school around age 14 or so, and since then, my life has sort of spiralled downwards. Interesting.

Anyway – this post is to try and describe depression as I understand it.

When some people think of depression, they think it means “aw, you’re sad? there there”, and think it’s something that can simply be gotten over. Some people think it’s a matter of simply snapping out of it. I remember people actually telling me that!

Depression is a sort of mental exhaustion – you do not feel the drive to do anything, and even if you do want to do something, it’s hard to dredge up the energy needed to get it done. I go to sleep every day at 10pm, and get up between 6am and 7am – I good 8-9 hours sleep – but I am always tired.

When I was 20-24, I used to carry knife blades around with me and cut myself a lot. It’s hard to describe why I used to do that – I don’t have a clear reason, and didn’t, even then. The reason I would give then was that it made me “feel alive”. I’m not sure anymore if that was true.

What I do know, is that even though I was not actively trying to commit suicide, I would not have minded if one of those cuts went a bit too far.

I think the reason I stopped cutting myself was that I realised that even though I did not care if I was alive or dead, some things interested me. A flimsy reason to live, I know, but that’s all I had.

Hmmm…. lost track of my point.

The last few days were a very low point. I found it especially difficult as we had some guests and I had to at least act interested in things. It’s depressing being depressed (pun intended!).

I’ve been going to doctors for years, trying to find out why I am so tired all the time. I never got a definitive answer. It just took a few minutes of talking for my present doc to spot it.


Over the weekend, I was feeling put-upon. I felt that I had somehow become the underdog – that should carve a big S into my head because I felt as if I was being told what to do by everyone.

I have felt like that before, but it was very strong over the last few days.

That, combined with a general feeling that my life was falling to shit (as I feel every few weeks) and that, despite my efforts over the last few years, there was no tangible improvement and that there was not going to be a tangible improvement ever, convinced me to go get help.

So, yesterday, I went to a doctor, described my feelings, and was pronounced Depressed.

I am now on happy pills. The doctor told me that it should not affect my work. I hope so. It’s very important to me. I have avoided the idea of taking anti-depressants for a very long time because I was not sure how they would affect me.

So there it is. The docs agree with me that there is a “problem”. I somehow feel better just knowing that!

I’m due for a proper clinical meeting by some head-shrinkers within a month, then I’ll know what classification of mad that I can be filed under.

timing some variations on a theme

I thought I’d test the speed of some comparison variations in PHP. Here are the results:

testing (!(6|5)) 99999 times: 0.40472507476807
testing (!(6||5)) 99999 times: 0.36446118354797
testing (!6 && !5) 99999 times: 0.37069892883301
testing (6==0 && 5==0) 99999 times: 0.44164681434631
testing (6||5)!=0 99999 times: 0.39538788795471

Numbers were hard-coded. Language is PHP 4.3

morning thoughts

Dive Into Mark has a funny, but eerily true account of the nature of developers.

Topic of the moment at #linux: Nargler 's brain has quit (Read error: Need Coffee)

I get up at 6:30am to rush preparation for leaving home at 7am, so I can read a book (Raymond E Feist: Shadow Of A Dark Queen) while walking to work through the rain. I arrive after forty minutes and four miles so I can have an early start without distractions, then I read blogs, news, and tutorials for an hour or so.

wordpress from console

Let me just tell you – this is not easy! I lost the action of one of the axes of my mouse earlier, and rather than struggle with a half-functional tool, I decided to revert to console. I’m not sure which is better… Lynx in text mode is not very good with the ol’ textarea.

Note to self: look into how wordpress handles pointy brackets.

Note to self: If you can smell anything from the kitchen; it’s burning!

Note to self: do not piss of GF, as she is on several mailing lists, and may threaten bars of soap.

Note to self: Aliens Vs Predator sucked, but it may be watchable once or twice before it settles into unwatchability.