The CSS position property

The position CSS property was my friend today, along with it’s co-conspirator, z-index. It helped me out with a situation where I have a footer which extends upward into the content area (a web-2.0-ish gradient to white) and the content partly overlaps. IE was as usual being contrary, displaying the footer on top of the text while every other browser had the footer behind it (The real irony here is IE’s behavior seems to be more “correct”, as the footer comes after the content in the HTML).

Giving position and suitable z-index values to the footer and content allowed the page to appear the way I wanted it to.

There’s a great writeup of these CSS properties titled “Give Me Some Zzzzz’s“) which by coincidence showed up today in one of my RSS feeds.

Especially useful was the note about how position works, and what an absolute positioned element is positioned in relation to.

Another byproduct of adding position:relative to an element is that the element now becomes the “containing block” for further positioned elements. This would allow you to define absolutely placed elements in relation to that newly created stacking context. The “containing block” of an element is defined as the nearest ancestor that has a value set for the property “position” other than static (e.g. the parent should be position:relative or position:absolute or position:fixed). If no parent exists then the containing block becomes the root element which is the HTML (or body outside of margins set), which effectively means the viewport.

Making a block position:relative has no impact on positioning (unless you specify top, left, bottom or right also).

Is your old laptop battery really as worn out as you think?

The PowerBook we have for site testing at work, and my old Dell Inspiron laptop, both had something in common: lousy battery life. The PowerBook claimed around 1 hour remaining with a fully charged battery, while my poor old Dell could barely reach 40 minutes away from a power outlet!

My thought, of course, was that the batteries, being old and used in laptops that were mostly on AC power during their lives, had simply lost most of their capacity, as li-ion batteries are prone to. Then I found out about “recalibrating” the battery.

Modern laptop battery packs are usually “smart” batteries; they have built in charge-monitoring circuits and can report their charge status to the computer. However, over time, the accuracy becomes suspect. By periodically bringing the battery to full charge, then allowing it to discharge to the point where the laptop shuts down or goes to sleep, then fully recharging again, the circuit is “reset”.

Naturally skeptical, I tried it out.

The Powerbook, at 100% charge and freshly disconnected from AC voltage, reported just over 1 hour remaining. After about an hour, it was reporting 1 minute of run time to go, and then…it kept running. It showed 1 minute for a while, then decided it could no longer calculate the remaining time and just said “calculating…” instead. Finally, two hours after going onto battery power, and over one hour after the Mac had started it’s dire warnings of lost data and could I please plug it back into the AC outlet now, thanks, it dropped into standby mode. One recharge later, back to 100% capacity, and now the battery run time says 2 hours! Running it down to standby again took about two hours, with the battery status reflecting this pretty much all the way. Not bad considering the thing is about 7 years old.

So, I tried it with my Inspiron. 40 minutes in, the battery status was at rock bottom, and again, it kept on running. I’m not sure for how long, but when I checked on it a few hours later, it had made like a bear in winter and gone into hibernation. Back on the power, back to 100% charge, and now it reports about 1 hour 30 minutes of wire-free power. Still not great, but then even at it’s best I could barely squeeze 2 hours on battery from this PC.

I don’t use the laptop on battery power often, but it’s nice to know I can rely on it a little better than I thought I could, without having to buy a new battery. On a more confidence-inspiring note, the Dell used to stay stuck at 98% or 99% and charging for hours, prompting me to remove the battery entirely lest it overcharge and become another one of those “hey look at my melted laptop” stories that have become all too common lately. Seems like that problem also went away.

If you allow your customers to contact you…

These days, your company, large or small, is nothing unless it has a web presence of some sort. Sometimes that web page is so badly done that it may be worse than having no page at all, but 21st century wisdom would suggest that having an online presence has become almost an essential part of marketing your business, even if you’re strictly a “bricks-and-mortar” operation.

One of the major advantages is being able to not only provide contact information for people who want to reach you, but also to provide a channel for direct contact by email or even instant messaging. What could be more powerful than giving customers a way to ask you something and receive a quick reply, without having to call and then sit around waiting for the next available representative?

With great power comes great responsibility, however. What could be more off-putting and damaging to your brand than having people email you a simple question and never receive a response at all? If you called a business and nobody ever picked up the phone, how long would you keep trying before you took your custom elsewhere? The same applies to email.

On Monday afternoon I emailed a large, UK-based company I have an account with, asking a very simple question. I chose email because I don’t much feel like waiting for snail-mail to reach them, or paying international call rates to listen to muzak for some unspecified period of time while someone in India handles all the calls that are in front of me just so I can then spend about 2 minutes talking to them.

One and a half business days later, and surprise! No reply. Not even a “thank you for your email, we’re on it”. I know they’re a large company, and probably get massive numbers of queries, but really, it was a simple question and should not have taken anyone too long to answer. So, I have to assume they either ignore email, or have so few staff tasked to deal with it that they have a multi-day backlog just to read the things.

If your business is going to accept email from customers, you’d better also put in place the resources needed to handle it in a timely manner. If you cannot do that, then don’t even bother with the email contact thing, you’re just going to do more harm than good to your hard-earned brand reputation.

Oh, and while I’m on a roll here, when your answering machine, sales staff or whoever asks me to leave my name and phone number, and promises that I’ll be called back, how about being courteous enough to actually do that? It’s just the same as the email problem, if you don’t bother to return a call then the least rude of your competitors is likely to receive my custom instead.

What’s *not* wrong with setup.exe?

Jeff Atwood asks “What’s wrong with setup.exe?

Short answer: That depends on the implementation. Truth is, most of them are plain awful.

It should be simple, but all too often there are too many steps, too many unnecessary technical questions, reboots required, and worst of all, multiple attempts to up-sell to a paid version and nagging “register now” steps. The most pathological cases I’ve endured in Windows may just qualify as cruel and unusual punishment.

To paraphrase Forrest Gump, setup.exe is like a box of chocolates, but some of the chocolates have been replaced with something else brown and gooey, and you really never know what you might get next time you reach into the box.

Let’s not even get started on the opaqueness of the process, there’s no way to know what that setup.exe just did to your computer (bundled ad-ware, anyone?) short of a before-and-after comparison of files and registry entries. I shouldn’t need to run an anti-malware scan after a software install, “just in case”.

Uninstalls are even worse. On this Windows box in work I have far too many packages with broken uninstallers, or no uninstaller. The ones which do uninstall seldom allow me to remove system-wide configuration files, so I have to go into Explorer and manually remove them anyway. “Add/remove programs” is full of old apps which I can’t get rid of (back to deleting manually, but then all the registry entries and orphaned “installed” programs in “add/remove” stick around). Oh, and of course there are applications which used installers, but don’t even show in “add/remove”.

It’s a recipe for bloat, waste and cruft. Is it any wonder that old Windows installs slow down and become unstable?

The OS X way of doing things does offer more control to the user, makes it much easier to remove old apps and figure out what is *really* installed, but I agree that it does seem odd that the user of such a user-friendly system is expected to do anything more than double-click an icon to start an install. It could be better, but of the two, I much prefer it. Drag-and-drop isn’t that hideous a task.

However, this is one area where Linux (with the right distro) has both well and truly whupped.

Taking the “no command line needed” approach in Ubuntu: launch Synaptic, enter your password, search for the packages you want, select them (saying “yes” to any dependencies which get flagged), hit apply and wait for them all to download and install. It works the same way every time. That might seem like a lot of steps, but they also include the locating and downloading process, which you’d otherwise have to handle manually, hunting around websites. Chances are very good that you’ll find what you need in the default repositories.

Installing a separately downloaded .DEB is a seamless process too, at least in the cases I’ve had to do that. Updating everything installed from the repositories is a matter of a few mouse clicks. Uninstalls actually work and I can choose to delete system-wide configs if I want.

It’s a straightforward matter to find out what was installed by any given package, too.

In short: total consistency, total transparency, minimum hassle, very user-friendly. (Isn’t Linux supposed to be hardcore and geeky? Seems like the opposite here.)

In fact the only annoyance I’ve encountered in a year of using it has been applications which don’t add themselves to the Gnome menus (games seem to be the primary culprits here). I can live with that, and could always file a bug report/feature request on the package so that less technically minded folks might not have the same problem later on.

Overlooking the obvious

I spent a surprisingly large amount of time last week trying to work out why CFFILE would not upload a file on our test system (in Windows) but was working fine on the live system (running Linux).

First I thought I was doing something wrong. Next, after much tearing out of hair, I uploaded it to the live server and found it worked fine. OK, fair enough, that works for now, and at least I know I’m not going completely crazy.

Today I revisited the problem and after much running in circles, discovered that I’d overlooked the most obvious reason: directory permissions. Sure enough, Coldfusion could not write to the image directory. Changed the permissions and now it works.

Can’t help but think I missed some important sign of what was wrong, but then programmers (myself included) have a nasty tendency to look for the complicated reasons for a problem, when the real, simple one is hiding in plain view (that’s why we make lousy User Interface designers). We never learn, either! ;-)

Expanding a box to contain floating elements, again

Back in February I found out a neat trick for making a DIV element expand to contain floating elements within it, by setting display: table.

Unfortunately it’s not so neat when you have a form inside of the table-styled element, and you’re trying to view it on Safari1. As I discovered today, the form just doesn’t display, unless you surround it with a plain old DIV. Hardly semantic markup.

I cast around for a better way, and discovered a post entitled “Clearance” on Mezzoblue, which explained two other ways around the problem.

The overflow: auto trick looked good, but had some unexpected side-effects. It displayed fine on almost everything including Safari, but some pages in Firefox added a vertical scroll bar into the content for no obvious reason. After a small amount of tweaking around with the CSS it turned out that overflow: hidden worked well too, rendering just the same way, but without the scroll bars, and as an added bonus stops overflowing content from busting through the right-hand border.

The fix is literally that simple: change display: table to overflow: hidden.

It also removes the need for a specified width attribute, except of course for the black sheep of the browser world, yes that’s right, IE 6, which was rendering all wrong without having something to force “hasLayout”, but was also having some rendering issues if I just used height: 1%; poor old IE6 just has to have a set width with what I’m doing, it would seem.

No problem, pull out the width section and apply it to IE6 and below only using the * html hack.


1 Version 1.3.something in this case. No, I haven’t tried Safari 3 for Windows yet, I’ll wait until people stop complaining about how messed up the rendering is before I test anything against it, thanks all the same!

Tool of the Day: Synergy

I do website development. I also care that my websites should display correctly, or at least be usable, on a wide range of browsers and platforms. This comes at a cost of course: to get the full-on cross-platform experience, you’ll need the full-on cross-platform setup.

You could use virtual machines (rather slow in my experience, even on a dually Xeon box), multiple real machines with a KVM switch (edit, flick switch, test, flick switch, edit…), or an Intel Mac with Parallels (same issues as a KVM switch, i.e. having to switch, but not so hard on the electricity bill), but the in-thing right now with VDU hardware getting silly cheap is multi-monitor setups and really, there’s nothing quite like just having to glance over at the other screen to see what’s going on. But then you have several keyboards and mice, or a switch, to contend with.

Wouldn’t it be nice to be able to just move the pointer on over to the other computer’s display, and have the keyboard control switch over to follow the mouse focus? Just like having one computer with multiple monitors, but with each display being a different OS on a different computer? Maybe your main one could have more than one screen itself?

That’s exactly what Synergy does. Your main system, with the keyboard and mouse hooked up, acts as a server, with the other computers, each with their own displays, talking to it over the network to share the keyboard and mouse.

Move the mouse off the edge of the screen and control goes seamlessly to a different system. At work I can edit a site’s source code on the Windows box, then move the mouse off to the right, onto the OS X machine running Safari to see how the edits shake down there. Or I can have the webserver logs showing on the Mac, and move across to interact with them without having to go over to the laptop’s keyboard. Want to stay locked in on one display? Enable Scroll-Lock (finally a good use for that key and it’s associated LED). The separate systems also share a common clipboard, and for Linux and Windows at least can synchronize the starting and stopping of a screensaver across all the displays.

Synergy has a few quirks still, but these are things which should get worked out. It makes the two-computer setup I work with at the office a lot more usable, and opens up some very interesting cross-platform possibilities, like this three OS, four screen setup.

One big advantage of open source

All software has bugs. Even open source has them. Programmers are human too (no, really!) and we make mistakes sometimes.

The nice thing about being an end-user of open source software though, is that I can report those bugs in a detailed way, and get feedback on whether they’re being dealt with.

When I ran into a problem with the Banshee music player and my iPod, I hunted for similar bug reports, and when none showed up, filed one. The bug is now fixed, which gives me a nice warm fuzzy feeling. Maybe it would have been found and fixed anyway, but the fact is that I could report the problem and see progress on a fix, and now the problem is gone.

If I had a great idea for some feature, I could file a feature request. It might not be implemented, but I’d likely be given a good reason for it’s non-inclusion.

Try doing that with proprietary software.

It also gives you a feel for how responsive a project is. The Banshee maintainers were all over this one, and that makes me so much more confident about using their software in future.

Granted, writing a bug report isn’t for everyone, but it’s not necessary to be a programmer to do it, either, and it really helps improve the product. That’s good for the project, good for everyone who uses it, and good for open source in general.

So, if you’re using open source software, and you’ve encountered a problem, don’t just sit around whining powerlessly about it and hoping it’ll be fixed in the next version. File a bug report. Use the empowerment that open source gives to it’s end users, and help make the software you use even better.

Now is the Time!

I promised myself I wouldn’t write any gratuitously snarky things about Microsoft, but the way they’ve been behaving lately with the whole “235 patents” nonsense, I just couldn’t help it, especially when I accidentally stumbled upon Jim Allchin’s Windows Vista: Now is the Time! sales-pitch to developers on MSDN (it turned up in a mostly non-related Google search, I swear!) Bear in mind it was written before Vista launched.

Are you ready for Windows Vista?

Yes, in the same way as I’m ready to have my eyes gouged out with a spork. In fact I think I’d prefer the spork.

We know the world is!

Are you absolutely sure about that? Only, there seem to be a lot of people who are with me on the spork thing. Some of them have barely mastered the power switch on a computer, but they know Vista is kind of stinky.

The business users, of course, already know better than to jump at anything Microsoft puts out until it’s had at least one service pack. So they’re ready too…ready to wait and see.

Barring any unforeseen quality issues such as bugs around data corruption, resiliency, or security

…or taking almost as long to copy a file as it did for you guys to bring Vista into existence. That’s basic OS functionality, you know.

We are very close to being done.

Apparently so. Rampant process slowing you down, restless developers who, I would suspect, don’t like the idea of software patents being waved around like loaded guns any more than we in the open source crowd do, lack of traction in the markets you don’t already hold a death-grip on, and your corporate obsession with out-Googling Google instead of focusing on your core business.

How long’s the next version of Windows going to take to hack together, a whole decade? The competition isn’t standing around waiting for you, and it doesn’t matter how much toothless patent FUD you spin out, that’s not going to change.

People will flock to software that is new, compelling, and “cool.”

Like Ruby on Rails, and AJAX, and all the other “cool”, compelling, new things that are being done in the online space.

Using non-Microsoft technologies. No Windows required, to use or develop. Just the way I like it.

Now is the time, indeed. Welcome to the New World Order, Microsoft. The tar pits are over that way —–>

Tool of the Day: console (Windows)

Sometimes I’m stuck with using Windows. Fortunately Cygwin helps out and gives me a nice Unix-y command line where I can get things done in a way I’m comfortable with.

But, the default Windows command line tool found in XP is, frankly, awful. It dates back to Windows 95 (or at least, it looks and feels that way). It doesn’t integrate at all, it’s ugly, and it shows how much Microsoft don’t care about giving the user choices.

Sure, you can use the command line tool. But it’s not very good, and we don’t really care, otherwise we’d have updated it along with the rest of the OS. We gave you a shiny GUI, why would you want some horrible nasty command line thing anyway, you freak?

And did we mention our new version of Windows is even shinier? Buy our new shiny stuff! Yay!

And no, Windows PowerShell isn’t any better. The shell itself is an improvement (how could it possibly be any worse than command.com? Still, it’s no zsh…), but it’s wrapped in the same useless terminal window as the default one. Ugh, no thanks.

So, I’ve been using PuTTY and an SSH server to give me a halfway competent command line, but it’s not exactly an optimal solution. Some Windows console apps (mysql client is one) will just hang, confused about where their STDIO is.

Today, I decided enough was enough and went searching. What I found was Console, a free, open-source replacement for the default command line tool.

By default it runs the normal command.com shell, but it works well with Cygwin too. Cut and paste behave more like one would expect of a Windows app, you can choose a font without hacking the registry, resize the window without editing the settings, and it has tabbed multiple terminals as well. Oh, and I don’t need to run an SSH server just to get a command line.

It’s a vast improvement, and I can highly recommend it if you use Windows and do any sort of command line work.