Posts Tagged geeky

One-Time Pad In Javascript

A few months ago, I spent one lunchtime writing a One-Time Pad Encryption/Decryption Engine in Javascript. I’d meant to blog about it at the time, but I forgot, but I came across it again today and thought it was cool enough to share with you all.

If you already appreciate why that’s cool, go play with it. If you don’t, allow me to explain.

What is a One-Time Pad and why is it awesome?

One-time pads are a form of cryptography which are simple enough to do by hand (you don’t need a computer, but it helps), versatile enough to transport any message, and – this is the clever part – completely unbreakable.

Yes, completely unbreakable. It doesn’t matter if you have a billion supercomputers and a billion years, a one-time pad is mathematically sound. So long as it’s used properly, it’s unbreakable, but it’s the difficulty and discipline required in using them properly – as well as difficulties in finding secure ways to share keys over long distances – that makes them impractical for widespread use.

They did, however, see a lot of use in espionage during the Second World War and the Cold War, and continue to be used today for some diplomatic messages, as well as occasionally by particularly paranoid civilians.

So what’s the story?

You’re probably familiar with the concept of a Caesar Cipher – you may have even played with them as a child – which is perhaps most-often seen nowadays in the form of ROT13. Put simply, a caesar cipher “rotates” letters through the alphabet, so perhaps A becomes B, B becomes C, C becomes D, and so on (in this example, Z would become A). So my message “IF YOU READ THIS YOU ARE GAY” becomes “JG ZPV SFBE UIJT ZPV BSF HBZ”. I can send that message to you, having already agreed with you the code, and you can roll each letter back by one (so A becomes Z, B becomes A, etc.), to get back the original message.

This is fundamentally flawed and offer no real security at all, of course. But suppose we made a couple of enhancements to our plain old Caesar Cipher. First, let’s add some punctuation to our alphabet (space, full stop, comma – we’ll treat these as letters in their own right which come after ‘Z’). Then, instead of rotating each letter in our message the same number of steps around, we’ll vary it. So let’s agree that the first letter will rotate 3 places, the second by 18, and the third by 11: then the fourth by 3 again, the fifth by 18, the sixth by 11, and so on. If we encode the same message now, we get:

  • I becomes L (rotated by 3)
  • F becomes X (rotated by 18)
  • [space] becomes I (rotated by 11)
  • Y becomes a comma (,)

And so on. Suddenly that’s a lot more secure than our plain old Caesar Cipher! Congratulations: you just invented the Vigenère Cipher. Unfortunately for you, it’s almost 500 years old already. Even more unfortunately, it’s still not very secure. It’s fine for passing notes in class, but it won’t do for sending orders to your agent on the other side of the Iron Curtain!

How is a One-Time Pad different?

The “key” to the cipher we used above is 3, 18, 11, and the problem is that the key ends up being re-used (repeated) throughout the course of the message. If the message was the word “ELF” (encrypted to “HAQ”), and we agreed never to use that same key again, then anybody who intercepted the message – even if they knew we were using a Vigenère Cipher – wouldn’t know what we’d said, except to say that it had three or fewer letters. We could equally have said “MAN” (using the key 8, 17, 8), “EAT” (using the key 0, 17, 14), or “EGG” (using the key 0, 23, 1). If we ever used the same key – 3, 18, 11 – again, our code would become vulnerable to frequency analysis, which is a technique for working out what the key might be based on the likelyhood of particular letters or words (especially common ones) being used in combination.

It’s pretty easy to see how to fix this: all you have to do is to choose a key that is at least as long as the message you want to encrypt, and never reuse the key.

This is how a one-time pad works. Suppose you and I agree a series of numbers, like this: 64191 25746 89891 93406 33604 89879. You keep a copy, and I keep a copy, and we never tell anybody else those numbers, or the order in which they appear.

When I want to send you a message, I first convert that message into a series of numbers, using a codebook or codetable. In the example codetable below – which has been optimised for the English language – the most-commonly used letters are represented by one digit each, while less-frequently used numbers are represented by two digits. So the message “STEAL THE PANTIES” becomes 82832 17890 83752 80148 33282. It’s important to remember that this still isn’t encrypted; it’s just encoded: turned into a format suitable for encryption.

If we often talk about “panties” in our messages (and who doesn’t?), we might add that word to our codebook to make it faster to write: for example, we might assign it the code “11″ – in the table above, the prefix “99″ means “look it up in the codebook”, so instead of writing “panties” as “80148 33282″, we’d write it as “9911″ – cold war spies had whole dictionaries of most-common words assigned to numbers to make them shorter to write out! That makes our message: 82832 17890 83752 99110. In this particular implementation, we add a padding zero to make it up to a nice round block of five digits.

Next, we encrypt the message using our pre-arranged secret key, 64191 25746 89891 93406 33604 89879. To do this, we just take each digit in the message and add it to each digit in the key, ignoring any “tens” column. So 8 plus 6 is (1)4, 2 plus 4 is 6, 8 plus 1 is 9, and so on, to get our encrypted message.

All you have to do to decode it is run the whole thing backwards. From each digit in the message, deduct the corresponding value in the key – if you get any negative numbers, just add 10 to them so that they’re not negative any more. Then run the resulting encoded number through your codebook to get back the secret message.

In practice, using a codebook is optional, but very-highly recommended. In the basic codebook I’ve provided with my implementation, the word “condition” goes down from being “71547 23833 54″ to just “99114 7″. A well-designed codebook will contain not only common words in your language, but anticipated words for the things that you expect to talk about in your messages (like “MISSION”, “CAPTURED”, and – of course – “PANTIES”).

Messages encrypted using one-time pads are so secure that it’s safe to send the message itself completely in the clear, which is exactly what we used to do. Especially during the cold war, but still today (and increasingly), governments have been able to communicate with spies in foreign countries simply by broadcasting strings of numbers over conventional radio, from what are called numbers stations by radio enthusiasts (and also by conspiracy theorists, of course). Of course, nowadays it’s perhaps more-feasible to send many kinds of messages by e-mail – and there are a number of one-time pad systems optimised for fully-computerised use, although there exists a greater risk of being traced online than by simply tuning in a radio.

Now: go have a play!

Click the link – One-Time Pad Encryption/Decryption Engine in Javascript – to try out my one-time pad engine and encrypt and decrypt a few messages of your own. It’s quite deliberately written in a way which does not communicate with my server at all, once the program has downloaded (unplug your computer from your Internet connection if you like, and you’ll find that it still works), so I’m not able to see what you’re encrypting. You can use your own codebook if you like, and the entire source code for the page should be reasonably easy to read, if you’re that way inclined. Have fun!

However, you certainly shouldn’t actually use it for passing secret messages around: read the caveats below if you can’t work out why for yourself!

Caveats

  • The first challenge with using one-time pads is finding a good secret key. People have used all kinds of things – patterns in music, entire text of books – that are all flawed and imperfect. The only secret key good enough for use in a one time pad is a cryptographically-random set of number. The random numbers generated by a conventional computer are not good enough: I suggest you get yourself five ten-sided dice and roll them all simultaneously, writing down the numbers which come up as they appear in front of you from left to right. Repeatedly. Yes, this is a boring process. For convenience, my implementation will generate random numbers for you, if you like, but they’re not good enough for actual use. The United States broke a German one-time pad in 1944 because the machine they used to generate the random numbers was not sufficiently random.
  • The second challenge is getting your secret key to the friend to whom you want to send secret messages. This must be done in person. If you transmit it by any other medium, it could already have been compromised. Even if you encrypt it, the system can only be considered to be as good as that encryption, which defeats the point entirely. During the cold war, KGB spies were issued with tiny keybooks like the one shown on the right. A book this small can be hidden in any number of places, as anybody who’s been geocaching knows! After receiving and decoding a message, the page used to provide the key could easily be burned, eaten, or otherwise destroyed.
  • A third challenge comes from the fact that no key must ever be re-used. As soon as a key is re-used, the code is no longer unbreakable. A combined U.S effort broke a 1945 Soviet one-time pad after the same key was used several times: once the U.S. knew something about the contents of some of the messages (they contained leaked British intelligence), they were able to partially break the key.
  • There must be no way for an unauthorised party to observe the plaintext before it has been encrypted or after it has been decrypted. Your desktop PC won’t do, because your enemy can read your screen through the wall, install a keylogger, or just peep through your window!
  • And, of course, as with all cryptography, your system is only as secure as the people involved. If your friend can be bribed, blackmailed, tricked or tortured into giving up information, the system fails. Obviously to maximise your ability to protect your system you should issue different keybooks to each of your trusted friends – this also helps to prevent them from talking to one another and organising a coup against you!

Further Reading

Tags: , ,

SuperGenPass In MicroB On The Nokia N900/Maemo

In the unlikely event that I’m not the only person who uses SuperGenPass to manage my passwords and MicroB on Maemo on my Nokia N900, here’s a few tips that I thought I’d share (they’re also valid on the N800 and N810 and “hacker edition” N770s, too, I expect):

  • You don’t have a Bookmarks Toolbar (where would you put it on a 3½ inch screen?), so once you’ve customised your SuperGenPass bookmarklet, you’ll need to click-and-hold on the generated link, and then select “Add bookmark” to save it to your bookmarks).
  • Use it as normal: either fill your master password into the form and click your Bookmarks menu and select the bookmarklet, or select the bookmarklet and give it your master password. Don’t forget when using complex forms or changing passwords that Maemo provides a full clipboard so you can copy/paste passwords around where the need arises (thankfully quite rarely).
  • If you’re irritated by the “You have requested an encrypted page that contains some unencrypted information” warnings that you see when logging into SSL-secured websites (and the fact that unlike desktop Firefox, you can’t turn it off from the settings), here’s how you disable it:
    • Enter the web address – about:config
    • Agree to the warning page, if you’re presented with one
    • Type “security.warn_viewing_mixed” into the search box, or browse the properties list for that option
    • Select it by clicking on it, and tap the Enter key to toggle it from true to false.
  • I don’t yet know the reason for the fleeting “Maximum number of characters reached” message, but it doesn’t seem to impact on functionality of SuperGenPass. Does anybody else know what it’s about or how it can be suppressed?

Tags: , ,

Nokia N900

I’ve just got myself a new mobile phone, and I thought I’d spend a moment to gloat about some of it’s more awesome features (and mutter under my breath about a few of the things that are less-fabulous about it).

So, my new phone is a Nokia N900. You’re not likely to have seen many of these floating around, yet, because they’re new to the UK and they’re currently in somewhat short supply, but thanks to some careful negotiation I’ve gotten my clammy mits on one just a little ahead of the curve.

I’m now loathe to say what I was initially inclined to about it – that it’s quite a remarkable phone – because it’s not really a phone (although it is quite remarkable). As somebody who has always gone for smartphones with heaps of geeky features, I’ve often gone through conversations like the one in the comic, above: where somebody has said “but can it make calls?” These comments tend to come from people who want a phone that makes calls, maybe sends texts, and little else, and often this “purist” view of mobile telephony somebody gives them a strange superiority complex (or perhaps it’s just a backlash against the feature-creep of modern portable devices: who knows). As for me, I don’t care – I want all of those extra features. I couldn’t imagine any more owning a phone without – at least – a fully-featured web browser, camera, bluetooth, wifi, and the capability for me to install (and ideally develop) my own applications onto it, such as connectivity tools, an instant messenger, and so on.

A Nokia N900 on a phone call

However, the Nokia N900 is the first communicator – yes, that’s the word I’m going to use, instead – where I’ve honestly felt that the telephony features “come second”. I suppose it’s the result of the natural progression of Nokia’s Nxxx range of PDAs that this should be the case – the N900 is the first in the series to actually support use of a mobile phone network at all; at least directly. In the device’s default configuration, out-of-the-box, supposing you wanted to make a cellular call, you’d need to:

  1. Switch desktops (by “swiping” one desktop along) or access the applications menu (by tapping the on-screen button for that purpose).
  2. Tap the “Phone” icon, which by default sits in 6th place on the list. Yes, 6th.
  3. Dial the number you wanted to call.

That’s about 66% steps more than just about any other phone ever made. (okay, there’s actually a faster way, but supposing you wanted to exclusively use the touch-screen interface, the above instructions are correct) I know a lot of people who would be put off by that, but I’m not one of them: I’m well past the point where phone calls are the primary thing I use my phone for!

There’s a few things that make the Nokia N900 remarkable by comparison to the phones I’ve had before:

Touchscreen (& hidden keyboard)

Superficially, the major change to my previous phones is the addition of a touchscreen, which seems to be The Thing if you want to make a smartphone these days, thanks to Apple’s innovations in that area. Unusually, the N900 also has a slide-out QWERTY keyboard. The slide-out keyboard takes some getting used to, because it’s best operated by your thumbs, which isn’t the way I’m used to using a keyboad. It also makes the phone almost twice as thick as the iPhone and slightly thicker than the HTC Magic, which may be a turn-off to those who like their devices skinny (again, not something that’s ever been a concern to me).

I’m quite pleased with the touchscreen. There’s a stylus embedded in the edge of the case (this is a resistive touchscreen, not a capacitative one like the iPhone, so a stylus can be used), which can be good for clicking tiny links on web pages without zooming in, sketching, and so on, but mostly I’ve just been using my big chunky fingers and that’s worked fine. While the hardware’s multitouch-capable, the factory-installed software isn’t (more on that later), presumably to avoid a lawsuit (there are a lot of complicated patents in that area right now), but having never owned a multitouch-capable phone I don’t miss it. Instead, there’s a good deal of standardised gestures – for example, drawing a spiral in a clockwise or anticlockwise direction can be used to zoom in and out.

The keyboard noticibly lacks a tab key, norkies (angle-brackets), and a few other uncommon pieces of punctuation, which is slightly disappointing (for a geek phone!), because acessing these using the alternate method is just slightly slower than would be ideal. Perhaps these could have been supplied as “special” characters on some of the keys which have no alternate function (e.g. the cursor keys): still, it should be reasonably easy to write this kind of functionality.

Operating System & architecture

Maemo OS screenshot

A particularly unusual feature of the Nokia N900 is it’s choice of operating system. It’s not that Linux-based smartphones are particularly rare per se – after all, Google Android is Linux-powered and the iPhone OS is based on a BSD kernel – but the thinking that’s behind the N900 that is unusual. You see, the N900 gives you root as-standard. If you want to install a different Linux distribution or completely change the one that comes with the device, you can – without “jailbreaking” the device or invalidating your warranty. The standard operating system for the N900, Maemo 5, is based on Debian Linux but with Matchbox and Hildon providing the GUI. This means that the entire operating system is open-source and virtually free of patents and restrictions, and the community support is quite significant. Plus, there’s something distinctly sexy about opening up a terminal on your new phone and typing “sudo apt-get install dosbox” onto it, and a few minutes later having a fully-functional DOS emulator running in your pocket.

I suppose you have to be my kind of geek to truly appreciate that.

Fresh from the factory, the N900 comes with the usual selection of tools – phone, SMS (Nokia have finally improved their stone-age predictive text system to a modern one with support for word-completion, Markov chains, and so on), address book, web browser (based on Mozilla Firefox, and with Flash 9.6 support – there’s nothing quite like watching Flash videos on your mobile, stutter-free), etc. There’s quite a lot more reliance on the community than on other devices: for example, despite the inlusion of an FM tuner in the hardware, there’s no software to support it unless you install it yourself. As a Linux geek, that suits me down to the ground, but this isn’t a phone for everybody – it’ll never be popular and it won’t hit the mainstream in the way that the iPhone and Android-powered phones have.

Want support for Ogg Vorbis in your media player (damn right you do): just install a community-supported codec package. Same goes for video formats, whatever applications or games you want, and so on. There’s a package to readily allow plain old Debian repo packages to “just work” on it, too, without recompilation, so there’s an immense number of applications already available without even having to go near the Ovi Store, Nokia’s answer to the Android Marketplace and the Apple App Store.

The hardware

Nokia N900 with keybord extended

If you’re the kind of geek who cares, the hardware for this device is really quite spectacular. But if you’re that kind of geek, you already know where to look it up… and if you’re not, you don’t need me to repeat it. Suffice to say that the N900 is nippy and responsive even when performing intensive tasks (like simultaneously restoring archives from parity files while listening to radio repeats on iPlayer and playing 3D-accelerated video games), thanks to a generous amount of RAM and a good seperation of responsibilities between the three (yes, three) individual processor cores.

This is a geek’s device, and it comes with all kinds of surprising extras for developers to tap into. As well as Bluetooth, the tilt sensors and accelerometers (some idiot has already written an app that detects how high you can throw your N900 based on what planet you’re on and the accelerometer readings – sounds like a quick way to break your new toy, to me!), two cameras (one a 5MP one, like the high-end Nseries phones), it’s even got an infared transmitter, so you’re only a copy of LIRC away from a universal remote, too.

Thanks to last year’s industry standards agreement, the N900 uses the new “standardised” mobile phone charger, so at least you shouldn’t have to throw out your charger ever again (at least, until mobile phones start charging by induction, as standard), and you’ll always be able to charge from USB. But in a genuine bit of Nokia care, the N900 box also contains an adapter that can be used to convert any old-style or even old-old-style Nokia charger into the new standard format, which is a world of awesome (what else was I going to do with my collection of Nokia chargers?). Thanks for thinking of us, Nokia. Oh: and the environment, I guess.

And now, the things I don’t like

It’s not all rainbows and kittens, though. There’s a few things about the N900 that haven’t won all of my praise and support just yet:

  • Why do virtually all of the default apps run exclusively in either “portrait” or “landscape” mode? Some applications will automatically switch when you rotate the phone, but not all of them: personally, I like to be able to browse the web in “portrait” from time to time! I’m sure it’ll be patched soon enough, but it’s a minor annoyance for now.
  • It would have been nice to have a physical “Task Manager” button on the device, for when a full-screen application has made the standard one inaccessible (this isn’t the iPhone – this is a true multitasking machine – so being able to switch apps “fast” would be nice, like we could on Symbian). On the other hand, there’s an app for that.
  • There’s no native A2DP support, so those “next track”/”previous track” buttons on your Bluetooth headset are officially useless. Would this really have been so hard to have in the standard package? Can somebody write it, please?
  • There are a few teething bugs in the first release of the Mail For Exchange package, which I use to synchronise my address book and calendar with my online accounts, resulting in some synchronisations simply failing (although failing-safely, of course: no data was damaged). Considering that Nokia have had working code to do this for several years now, porting it and then testing the port really shouldn’t have been so difficult.

So there we have it

An official thumbs-up from me, so long as you’re a geek and don’t mind the fact that this phone is – for the next month or two, I suspect – going have have the kinds of teething problems I’ve listed above. I’ll reiterate that this isn’t a phone for a regular Joe: if you’re not going to appreciate the freedom you’ve got with a device like this, you’d be better to save your money and get a HTC Nexus One or iPhone 3GS, or hold on for a couple of months and check out the spectacular-looking Sony Ericcson XPERIA X10.

The N900 is a phone for people with balls and a passion for the most open of open-source. And it’s awesome.

Tags: ,

Your Experience May Differ

To: Daniel Hill <dlh9@….>
From: Dan Q <dan@….>
Subject: Aberystwyth University Is Awesome! Warning: Your Experience May Differ.


Dear Daniel,

There’s an age-old tradition amongst Aberystwyth graduates, and in particular amongst Computer Science graduates. But to truly understand it, you first need to understand a little bit about Aberystwyth University. Also, to understand recursion, you must first understand recursion (you’ll “get” that joke by your second year, if you don’t already).

As you know, your username is “dlh9″. There’s a reason for that: The letters are your initials. “But I don’t have a middle name,” I hear you cry (or, at least, not one that the University know about), “Where’s the ‘L’ come from?” Well, it turns out that Information Services, who look after all of the computer networks, have a System [TM]. And their System [TM] is that staff get usernames like “abc”, undergrads get “abc1″, postgrads get “abc12″.

(this has lead to some awesome usernames: for example, “bed” used to be the username of somebody from Residential Services, and “sad” was once the username of one of the counsellors at the Students’ Union)

Anyway, I digress. I was talking about usernames. The digit in your username is the year you started your course. So, because you’re starting this year, yours is “9″ (see, ‘cos it’s 2009 – get it?). You’re not allowed to spend more than nine years getting your degree, so that’s a pretty good primary key (you probably know what one of those is, but if not, you will before the academic year is out). Postgraduates get two digits because they often hang around for years and years. I don’t know what would happen if somebody spent a century getting their PhD, but I’m guessing that it wouldn’t be pretty.

And so there’s been a long-standing tradition amongst Aber grads, and particularly Comp. Sci. Aber grads, and especially particularly Comp. Sci. Aber grads-who-graduated-and-got-jobs-in-Aberystwyth and never got around to leaving… that when their username comes up for “renewal” – when a decade passes after they first started their course – they finger (you’ll learn what that means soon enough, too) the Aber computer systems and check if their username has been re-assigned. It’s a great way to make yourself feel old, as if the annual influx of younger-every-year Freshers didn’t do that perfectly well already.

Over the years, I’ve seen many friends play this little game. Some of them won, but most of them lost – it turns out that the odds aren’t really on your side: there are 17,576 conceivable username combinations each year – from aaa9 to zzz9 – and only 3,000 new students, so odds are less than 50% whether or not you ignore the statistical biases that mean that things like “qxz9″ (Quentin X. Zachary?) are basically never going to turn up.

So imagine my surprise when I, for the first time, get to play the game, today… and I not only win, but I get a double-win, because the person to whom my old username has been recycled is an undergraduate in my old department!

Yes: I was the last owner of “dlh9″. I was “dlh9″ from 1999, when I started, to 2004, when I graduated, an alumni of the Computer Science Department at what was then the University of Wales, Aberystwyth (it changed it’s name to Aberystwyth University shortly afterwards – this, combined with the fact that I have since changed my name by deed poll, means that I am the proud owner of a degree certificate that contains neither my name nor the name of an existing university!). At the time, my name was Daniel Huntley – I didn’t have a middle name, either – and I spent five years getting a four-year degree in Software Engineering before I started working for a software company here in this very town. I haven’t yet got around to leaving.

It still feels strange to write an e-mail to your e-mail address – my old e-mail address. It feels like I’m writing an e-mail to myself. I wonder what I’d have made of it if I’d have received this e-mail when I first arrived at University. It’s not so hard to imagine: the person I am now would be unrecognisable to the person I was back then, just like I am a complete stranger to you, but writing to you nonetheless. But even if you discard this e-mail and never think of it again, you’ll have done me a wonderful service by allowing me the chance to participate in a fascinating thought experiment that has granted me a great and deep nostalgia for the time I spent at that University.

(by the way; I apologise if your e-mail address is still getting the spam it used to get when it belonged to me)

Like me, Aber’s changed over the last ten years. The University’s changed, and the Computer Science Department has changed too. But I’m sure that you’ll find the place as beautiful and as satisfying as it has always been: this remarkable town on the West coast of Wales, where the mountains meet the sea, full of strange and quirky characters, a million miles from anywhere, and truly unique. I find myself longing for you to have *my* experience of Aberystwyth; to do all the great things I did, to meet all the great people I did – but you won’t. You won’t have the same lovers; you won’t discover the same music; you won’t join the same clubs; you won’t have the same beautiful sunsets while you roast burgers on disposable barbeques and the rising tide laps at your ankles; you won’t have the same hangovers; you won’t scrape through the same exams; you won’t steal the same traffic cones; you won’t climb the same mountains. A different story told differently.

You won’t have any of the things that made my time here in Aberystwyth so wonderful for the last ten years, but don’t dispair, because you’ll have something far better – you’ll have all of your own marvellous experiences. Mine are mine in nostalgia alone, but yours are yet to come. And I hope you have an ass-kickingly good time, because that’s what every Aber Comp. Sci undergrad deserves when they come to this magical corner of the world.

When you get as far as your lectures, tell Richard Shipman I said “Hi”. That’ll put you in his good books, I’m sure. ;-)

And if you see me around town, give me a wave and I’ll buy you a pint. If you got nothing else from reading this old man’s drivel, you just earned yourself a free pint. When I was a student, I’d have called that a win-win. Your experience may differ.

Good luck, and best wishes;


Dan Q

http://www.scatmania.org/

Tags: , , ,

jQuery Is Awesome. Yet Again.

I know that this probably isn’t news to any of you who care about such things and follow the world of web development even a little… it’s not even news to me, really – I’ve been an advocate of this particular programming library for a while now. But today in particular, I just felt so enamoured by the elegance of the jQuery Javascript Framework that I had to tell you about it.

This line of code:

$('.alpha').not(':has(.beta:visible)').hide();

Hides all elements with the class “alpha” which contain no visible elements with the class “beta” (i.e. if it contains any visible elements of class “beta”, the “alpha” is not hidden).

And it’s just beautiful. Just to compare how elegant it is to something else, here’s the equivalent code in Prototype, another popular Javascript framework, which in itself still shortens the amount of code that this would take in plain-old vanilla Javascript:

$$('.alpha').each(function(element){
var has_visible_beta = false;

element.childElements().each(function(inner_element){
if (
inner_element.hasClassName('beta') && inner_element.visible()) has_visible_beta = true;
});
if (
has_visible_beta) element.hide();
});

(okay, that Prototype code could probably be a hair simpler, but you get my point)

Wow.

Tags: ,

My New Pet Hate

I have a new pet hate.

A personal pet hate of mine for a long while has been that often, when I ask somebody for a screenshot to show me what’s going wrong with some software they’re using, they’ll take a screenshot or two, then paste them into a Microsoft Word document, and then e-mail me the Word document.

Why would you do such a thing? You’ve got Paint: paste it into Paint and save it, and you’ll get:

  • A faster result. Paint loads a lot faster than Word.
  • A smaller file. Even a Bitmap saved in Paint (the default) will usually be smaller than a Word document. A JPEG or a PNG will be even smaller still, which means it’s more suitable for e-mail and be faster still.
  • A more-compatible result. Just about anybody can open whatever you produce with Paint, without requiring a word-processor that’s compatible with the version of Word you’re using).

And that’s without even looking at the benefit directly to me: that I don’t need to re-extract your pictures so that I can upload actual pictures, not a document, to our bug tracking system, or the benefit that I can view thumbnails of your screenshots to sort and manage them easily.

But no; I have a new pet hate:

It’s when somebody who’s using Microsoft Outlook sends me a HTML e-mail with several screenshots… each one of them inside a separate Word document attached to the message. WTF?

  1. You could just have pasted the image straight into Outlook. Less work for you, easier for me, faster for everybody. It’s just like pasting it into Word, except you don’t have to open Word (or create a new document), and the images end up stored more-like actual images attached to an e-mail.
  2. One Word document per screenshot? Why? Do you just enjoy thinking about the fact that I’ll now have to open 15 – yes, 15! – different Word documents just to extract the screenshot from each and save it as an image file like you should have in the first place!

Sorry; it’s probably just me who gets bugged quite so much by this.

Tags: ,

My Firefox Window

It didn’t occur to me until somebody looked over my shoulder and commented on it, today, that I actually have an at-least slightly unusual layout for my Firefox window. I thought I’d share with you all the thinking behind the particular collection of add-ons and tweaks that go into my day-to-day web browsing:

I’m a big fan of maximising the amount of screen real estate available for browsing, minimising the chrome that surrounds it. That’s why I use the LittleFox theme. It’s not the prettiest theme around, but it’s tiny, simplistic, and works with every version of Firefox I’ve ever thrown it at. It saves space by reducing the size of icons and excess space around tabs and buttons, and it does a great job of it.

To save even more precious vertical space (and because I’m generally running at high screen resolutions, and can spare the horizontal screen space), I combine my menu bar, toolbar, address bar and search boxes into a single toolbar. You can do this by right-clicking on the menu bar and clicking “Customize…” I drop the refresh, stop, and home buttons. I never pressed refresh nor stop anyway, always using the shortcut keys (F5 or CTRL-R, and ESC, respectively), and I my homepage is about:blank. On computers running at lower screen resolutions I’ve previously used the Searchbar Autosizer add-on to tuck-away the search box when I’m not using it, but nowadays I rarely bother.

I frequently find myself with dozens of tabs open, and I loathe it when tabbed applications force me to “scroll” left and right through my tabs (I’d rather my tabs just got narrower and narrower, until only the favicon remains), so I use about:config to change the browser.tabs.tabMinWidth setting to 0, which, after you’ve restarted your browser, changes this behaviour.

In addition to the add-ons that can be seen in my status bar – ColorZilla (in the bottom-left, so not visible in the screenshot above), Adblock Plus, FireGPG, Firebug (and a few extensions), Google Reader Watcher, Greasemonkey, HTML Validator, NoScript (with noscript.firstRunRedirection set to false, to stop it’s nagging), and ShowIP, I use one further add-on to tidy up my “bookmarks toolbar”.

The Status Buttons add-on gives you the capability to drag-drop any other user interface component into the right-hand side of the status bar: I use this to move the entire contents of the Bookmarks Toolbar down into the status bar, tucked out of the way. I remove the titles from most of the bookmarks (I can identify these, my most-frequently-used sites, by their favicons), adding them only where there’d otherwise be ambiguity as to the purpose of the icon.

All of these tweaks give me a huge browsing space that works the way that I want it to. I’m a heavy user of keyboard shortcuts – I pretty much only use the mouse to click hyperlinks and the buttons in the status bar – so this kind of layout suits me very well. One of the great things about Firefox is it’s flexibility: that you can make these kinds of tweaks so easily. And hopefully if you’re a similar kind of power user you’ll take some of these tips and be able to make use of them, too.

Tags: , ,

Internet Explorer 8 More Popular Than 6

Today is a good day for the web. Internet Explorer 8, which actually has reasonably good standards support, is now more widely-used than Internet Explorer 6, which is horrific to code for (Internet Explorer 7 isn’t much better).

It’s always been hard to write good quality web sites that work in Internet Explorer 7 and below: generally, I’ve always taken the approach of writing sites to comply with the standards and then to put in hacks specifically to address the problems introduced by IE6 and IE7. The sooner that we can disregard these browsers, the better.

Despite the stupid marketing campaigns Microsoft’s been pursuing to try to increase adoption of IE8, I’m at least a little thankful that they’re apparently working. I’ll be so glad the next time I can launch a site and not even have to think about using <!–[if IE 6]> conditional comments.

Tags: , ,

The Latest Stupidity From The Internet Explorer Team

Have you seen the latest stupidity that the Windows Internet Explorer team have come up with? Ten Grand Is Buried Here.

The idea is that they encourage you to give up whatever browser you’re using (assuming it’s not Internet Explorer 8), calling it names (like “old Firefox” if you’re using Firefox, “boring Safari” if you’re using Safari, “tarnished Chrome” if you’re using Chrome, and… “that browser” if you’re using Opera) and upgrade to Internet Explorer 8, and they’ll be giving out clues on their Twitter feed about some secret website that’ll only work in IE8 at which you can register and win $10,000AUS (yes, this is an Australian competition).

After looking at the site in Firefox, Safari, Chrome, and Opera, I thought I’d give it a go in Internet Explorer 8. But it didn’t work – it mis-detected my installation of IE8 as being IE7 (no, I didn’t have Compatability Mode on).

In the end, though, I just used User Agent Switcher to make my copy of Firefox pretend to be Internet Explorer 8. Then it worked. So basically, all that I’ve learned is that Firefox does a better job of everything that Internet Explorer does, including viewing websites designed to only work in Internet Explorer. Good work, Microsoft. Have a slow clap.

Tags: , , , , , ,

Zero Punctuation Reviews Duke Nukem Forever

And it’s a work of art. Go watch it.

Tags: , , ,