Skip to: Navigation Content Search


Diplomatic immunity through JavaScript April 5th, 2008

Would you love to be able to waltz in to a place, piss all over the floor, without anybody saying or doing anything to you? Even if they wanted to punish you, they would have to follow a process that you yourself defined. Haw haw!

Anonymous, self-executing functions can allow you to do this. They’re kind of like diplomatic immunity for your browser and can be very powerful.

(function(){/*
    Oooh it's so cozy in here. I have access to all
    global variables but I can do what
    I like and no-one will know!
    Now I'm going to do some private things.
*/

var privateVar = "I'm so lonely in here";
var privateFunction = function(s){ alert(s) };

/*

Okay, maybe I want to share something with the
    outside world but let's namespace it just in case:

*/

return namespace = {
           publicFunction : function(q){
               return function(a) {
                privateFunction(q + privateVar + a)
               }
            }
};

})();

We can’t access any of the private variables or functions from outside our anonymous function, thus avoiding collisions and overwriting, but we can return public functions that do! namespace.publicFunction is able to see, use and modify our private variables, but only in the way in which we want it.

It’s even possible to throw a bit of curry in there to spice it up. Calling namespace.publicFunction and passing it an argument (in this case a question) returns another anonymous function that expects an argument (an answer) and will then use our private variables to construct a little dialogue.

We would call it like this:

namespace.publicFunction("How are you?\n")("\nThat's too bad");

The example is basic and doesn’t make much practical sense but it demonstrates the way scope works in JavaScript and it can be a simple but handy tool to have in your arsenal.

A flying f*%kup March 28th, 2008

You’ve spent years and swathes of cash planning a major upgrade. Importing the best engineers, business consultants, designers and researchers, you’ve planned your project down to the finest detail, assessing risks, inviting all the right stakeholders to contribute and undertaking stringent testing procedures before launch.

There are no cutting corners and no getting it wrong - you’re upgrading once of the most important and most highly trafficked sites in the world and any downtime would have a severe effect on a large number of people.

Going live - the moment you’ve been waiting for for what seems like years has come. Are we ready? Have we checked all the systems? Is everyone trained on how to deal with the infrastructure and networks? Is our backup plan prepared?

“Ok! Flick the switch!”

Nothing.

“Flick it again!”

Still nothing.

The pressure is mounting. Complaints start to trickle in. Your visitors are wondering what is going on as there is no service. Total chaos ensues.

No, I’m not talking about a website now, but Heathrow Terminal 5. My trip to Amsterdam to see Mark Knopfler in concert, planned months ago, has been thwarted by “a catalogue of errors“.

A Romanian Easter March 26th, 2008

“What types of agricultural goods does your country export?” is not a typical ice breaker you’d use in conversation, but in rural Romania, where every square metre of land has been tilled for some purpose, it’s a serious question. And they expect an answer.

The relationship between people and land is more evident in Romania than any European country I’ve visited. Transylvanian roads are dotted with locals selling essentials such as eggs, turnips, faggots (bundles of sticks), home-made wines and cheeses, baskets and a products from every exploitable environmental resource. The land is their livelihood, their playground and sadly their rubbish tip.

Man at Bran markets

While conservative with their consumption, Romanians seemed liberal with their wastage. Along the roadside, the fields are littered with plastic bags and bottles. Spectacular snow-capped mountains and forests are connected by rusted pipes than run across the landscape towards the giant cooling towers of industrial towns. Indeed the country has a run-down air about it: outside Bucharest the buildings appear exhausted and stained; high-density apartment blocks queue beside abandoned factories apparently waiting to collapse to make way for the next generation. Spurts of EU funding are visible: dual carriage ways connect major centres, although it is still common to share them with donkey-drawn carts carrying wood, manure or entire families.

Coming from western Europe, Romania appears insanely cheap. You can feast on a local dish of grilled chicken with ham and garlic potatoes, polenta and mountains of fresh bread, a few litres of Ursu (the local beer named after bears) for around £7 or 30 RON (Lei). The average Romanian wage for a worker in a city company we were told is something in the vicinity of 500 Euros, with the rest of the country receiving a lot less, but they survive because inflation is low and so is the cost of housing. But people are nervous about the shift to the Euro which they say will drive up the prices, like they did everywhere else.

The low wages are probably why Romania jammed with Romanian tourists - it’s just too expensive to travel elsewhere. The castle of Bran where the Royal family once lived and, supposedly, Vlad Dracul, teems with Romanian travellers and their families with the odd Spanish or French and even Australian (!) making up the minority of gawking, photo-carrying pilgrims. Nevertheless, always on the look out for a business opportunity, market owners sell their homogeneous wares in these areas hoping to entice tourists to buy tacky Dracula mugs and t-shirts, wooden swords and vampire teeth.

Doing business in Romania is a rather informal affair which might come as a surprise to unsuspecting westerners who expect contracts, offices or even business names. In Romania these commercial excesses are optional. The rental car dealer from which we hired our 4WDs (one of which wasn’t a 4WD) consisted of two gents in full denim with bad teeth in the car park. They were nice enough and didn’t try to con us, although at 250 Euros for each car, we knew they had the better end of the bargain.

The hostel in Bucharest, which we found only by luck since there was nothing external to indicate that we’d arrived, was a converted house or nunnery with only three rooms, each fitting eight people. Even the girl working at reception was forced to sleep in a plastic banana chair behind the desk. About to retire for the night, I passed her thinking that she was taking a rest,

“Feeling tired?”

“Yes, hopefully tonight I’ll be able to get some sleep”, she said and smiled as she then proceeded to prepare her make shift bed out of what I’d have felt uncomfortable on after one hour (even after a dip on some sun drenched beach, a margherita and a 15 minute massage).

Our attempts at speaking the local language were met with mixed reactions. According to our taxi driver in Bucharest, who thought it would be a riot to hear four foreigners stammering instructions in Romanian for quarter of an hour before revealing that he spoke English, told us that half the country spoke English to some degree. His claimed seemed rather dubious in our experience. In Brasov our linguistic repertoire was tested on numerous occasions - our local corner store consisted of a half-metre square hole in the wall and was run by a friendly lady in a grey apron with a profound patience for the warbling of foreigners. The fact that we couldn’t see what we wanted to buy thwarted our usual method of pointing and thrusting money in all directions however our pronunciation of lapte (milk) and pâinea (bread) must have been half close as both products were handed to us with efficiency.

I was impressed with the way Romanians were interested in the world beyond their borders. At a remote petrol station, the same guy who had inquired about the state of primary industry exports in Australia also informed me that he’d learned English from the television, and much of it from an Australian drama called McLeod’s Daughters, which was hugely popular in Romania. His lack of twang in his accent made me suspicious, but to his credit, his spoken English was good. I watched some Romanian television while there and can admit that I didn’t experience any of this osmotic effect with the exception of picking up that the word crap means carp and that fried crap is an infinitely entertaining item to read on a menu.

Romania is known to have the largest population of European bears roaming around the wilderness. We didn’t see any but we did see many dogs. There are hoards of them, everywhere. Our guide books reported that there were 200,000 stray dogs in the country, but it seemed like a gross exaggeration when we looked about. You’ll see dogs in the cities rummaging through bins for food, sleeping dogs, lone dogs simply sitting in a fields doing nothing or marauding packs. There are dogs of all breeds (although mostly of the mongrel variety) and sizes. The strange part was that most of them seemed healthy unlike their best friends who, in the rural areas, were weathered and bent from whatever struggle they’d endured throughout their lives. Perhaps it was a symbol that, even in a former impoverished Eastern block country, there are opportunities to be had by the tough and street-smart.

I’d go back to Romania in a second. Everyone was very nice to us, even the policemen who pulled us over for going 70 in a 50 zone (even though we were driving at the same speed as the lorry filled with turnips in front of us) and only gave us a warning despite our licences not being valid. And the country side, beyond the rubbish is in some areas untouched and pure. What really impressed upon me though is the air of optimism - it’s a country that is growing and having joined the EU last year, you get the feeling that the people suddenly feel part of a world that for so long seemed to be passing them by.

Journalists love developers love journalists March 18th, 2008

The convergence of media has given rise to some strange bedfellows. Once upon a time a news room was filled with copy editors, journalists, photographers, phones blaring, and daily deadlines. Now it’s more common to see plasma screens, banks of computers, a multimedia department and us - the proud web developer.

A good working relationship between developers and the “journos” takes some time to forge: it depends on the environment and the willingness of both parties to accept and comprehend each others’ roles. But because these roles are so different, misunderstandings are inevitable. In some places, I’ve noticed a level of antagonism arise between the two groups where each regard the other as an ignorant impediment to their own jobs.

Developers take great pains to craft and maintain clean and compliant code and become disillusioned with the editors’ constant and successful attempts to break it. They can’t fathom how an editor would input 100 break tags to clear an image and consider a little piece of coding knowledge in an eager writer to be a dangerous thing. To a developer, an editor is someone whose basic role is akin to data entry. It is inconceivable that they should require any other skill beyond copy and paste and HTML tags beyond <h2> and <p>.

Editors on the other hand, think that developers are a team of geeks who, because they don’t want to do any work, enforce draconian rules on the publishing process and stifle any attempt at creativity. Editors feel that developers don’t understand a thing about the craft of news writing and the importance of timely and topical messages. They use acronyms to confuse and hide behind their inability to deliver what an editor wants.

Wording, coding and loading

Fortunately, I’ve been in both chairs. As a writer hacking away at a desktop word processor composing articles destined for the web, I was on intimate terms with the way text had to be “cleaned and gleaned” before it was suitable to be published as HTML. Any variations on the template (usually defined by designers) had to be fudged or “requested”, meaning that a designer had to create them and a client side developer had to provide the code. In a news environment, more so in an online environment where we can break and update stories when and from where we please, this is a huge frustration.

So too having worked with editors and journalists across many industries in a development capacity, I have heard their frustrations with regards to technology: “Why should we have to learn HTML and CSS? Don’t we employ people to take care of that for us?”

My answer was always that they should learn simple HTML and perhaps a little CSS, or at least what it’s used for, and that I would offer to teach them what they needed to know. Some accepted and others spurned the offer as if I’d just invited them to watch moss grow on roof tiles. But I understood their complaints. Arguably, more than in any other sector, the media and entertainment industries are experiencing profound changes due to the rise and rise of the internet. Concurrently, all the platforms, a great deal of the content, the language and yes, the roles are changing with it.

In today’s web-focused newsrooms the journalist is expected to not only produce the content but to publish it at well using whatever tool is provided for them. They’ve been employed to write, edit, research and provide the content that keeps people coming to the site, but the variable output of content management systems and the strict rules that are required to maintain a website that validates create a digital minefield. Training and documentation might be non-existent, technology changes but the pressures to submit their copy in a presentable format remain the same. For example, if a means to create a breakout quote is not available to the editor, who has to immediately push out a breaking story, they will improvise and we, the support staff who look after the integrity of the site may come across something like this:

<p ALIGN=LEFT><b>
<font size="3" color="red">
"And a minister said something interesting."<br>
</font>
<i>The Hon Henry Honeybun</i>
</b>
</p>

The writers don’t care. Their material is out and they’ve done their job. Any self-respecting web developer however is prone to suffer a mild spasm. Larger organisations that can afford to hire technical support staff who can respond to these events straight away have mitigating buffers. But the night desks and smaller news teams will publish what they can get away with, despite breaking the layout or every rule in the HTML validator.

Who’s right?

It might be a gratuitously evident comment, but people publishing content to the web - whatever that content may be - should have the tools and knowledge available to them to do so. Saying I work as a writer shouldn’t negate the necessity for me to understand the medium in which I publish. I should know what I can and can’t do and follow the advice of the developers.

But, it goes both ways.

If I am a developer (responsible for the front end of a news website), it’s important for me to know how about how a newsroom works and the role of journalists. It’s also worthy to understand how people in my team will be publishing to the site and providing adequate support for them to do their jobs properly. Providing the right tools is only a part of this. Attaching a digital style guide to the formal style guide is one option. Proper training is another.

Despite the gaps in the knowledge of both parties, I think we are at the tail-end of the transition and that we will see a new generation of journalists who will have had training in web publishing. Accordingly I hope that we’ll see a new breed of developers, particularly those bloggers, who appreciate the art of the word and the importance of a journalist’s or editor’s role in the creation of news. Ultimately we’re both producing lines to achieve the same end: whether they’re words or code, our medium is online and our audiences shouldn’t have to know that there’s a difference between the two.

On the edge in SW2 March 8th, 2008

Brixton is where I chose to hang my hat in London. This reveals nothing special until I tell you that my image of England before coming here for the first time was one in which people were a bit uptight but generally good-humoured with a wonderful comprehension of satire, wearing brown corduroy and emanating that air of sophistication that used to be revered back in the colonies. It was further coloured by the fantasy of a fine pub-loving culture and fresh rain on ancient streets where the expectation that the Goodies could leap out at you from any corner dressed as nuns or amuse you with some comparable hilarity, was reasonable to entertain.

So you can imagine how my illusions were shattered when I first laid eyes on my new suburb.

Read the rest of this entry »

Frontend developer wanted February 29th, 2008

Since I’ve worked as a frontender/web dude in a few countries now in the last few years I thought I’d impart my, albeit limited, knowledge on the current state of the market for us webbies in the cities I know more or less something about. As you are probably aware, things are better in some places than in others and I’m not just talking about the remuneration: the cost of living and the environment are all factors that will determine where you end up.

Read the rest of this entry »

Learning curves February 27th, 2008

I recently helped a colleague rebuild his site the CSS way after he’d spent hours at home trying to do it himself. This guy was no computer novice - he’s a fine python/ruby programmer and writes Linux applications in his spare time, but he just couldn’t get the whole logic of CSS and how it related to elements on the page. I understood his frustration.

Read the rest of this entry »