Google Chrome : array evals return out of order

I just want to make others aware of a little quirk with Google Chrome’s Javascript engine (V8), eval’d associative JSON arrays (aka objects) are returned in the incorrect order . The problem is that the engine doesn’t do what a programmer would expect it to do, but the programmer should be aware of why its happening and that it does happen.

Basically, take the following psuedo associative array/object and its corresponding JSON version:

Psuedo Associative array
Array (
 3503 => '',
 3847 => '',
 6852 => ''
);

JSON Array
var data = {3503:'',3847:'',6852:''};

Pretty basic huh? But that happens when we loop over this array/object? In Firefox, Safari and IE we get the same result, which is the array elements in the order listed above. Chrome on the other hand returns the items out of order. Now I know you are probably thinking, “its an array/object, order doesn’t matter”. This is technically true, but not if you are relying on the order for some reason, then you might find bugs cropping up. Check out the code below:

var data = {3503:'',3847:'',6852:''};
var s = '';
for(var i in data) {
	s += i + ',';
}
alert("Expected order: 3503,3847,6852\nOrder observed: " + s)

Firefox, Safari and IE all return the following alert:

Expected order: 3503,3847,6852
Order observed: 3503,3847,6852

Chrome on the other hand returns this:

Expected order: 3503,3847,6852
Order observed: 6852,3503,3847


Weird! Give it a try in your current browser by clicking here

Javascript guru, John Resig, has posted a note about this:
http://ejohn.org/blog/javascript-in-chrome/

Or for the official bug reports:
http://code.google.com/p/v8/issues/detail?id=6
http://code.google.com/p/chromium/issues/detail?id=883

As always with javascript programming, expect the unexpected… and…
Be Warned!

15-09-08 at 11:48:11
Trac ticket: reset to new

We have recently moved from Mantis to Trac at work for our bug/task tracking, but we have encountered a slight issue with Trac’s workflow management. The issue is that we wanted to be able to move a ticket from the ‘assigned’ state to the ‘new’ state. This is a common scenario if a team member leaves or goes on holiday while they have tasks assigned to them. Quite often you wouldn’t just want to blindly ‘reassign’ these issues to another member, but reset them to their new status so another member can pick the task up when they have the time.

We decided to introduce a new state called ‘reset’ in the trac.ini [ticket-workflow] block which allows us to easily reset a ticket to the ‘new’ status as if it had just been created in the system. The new block looks like this:

reset = * -> new
reset.operations = del_resolution
reset.permissions = TICKET_MODIFY

Now at the bottom of each ticket, we have an option which says:

[ ] reset  Next status will be 'new'

Hope this works for you too :)

25-08-08 at 15:28:41
Tweete : a New Mobile Twitter Client

After months of complaining about the lack of features on the official mobile twitter client, and the download overhead of slandr, I decided to write my own mobile twitter client. One that focuses on most needed functionality without the huge download overhead. I call it Tweete.

I’m still working on Tweete, but at the moment I have a beta release running that you are welcome to try out which you can find here: m.tweete.net. I’ve tried to keep the pages fairly light, at the moment each page is around 5k, which is roughly the same as the official mobile twitter client, but Tweete has extra features. Slandr on the other hand is around 25k per page load (last time I checked). My mobile handset browser (WM6 IE) doesn’t support gzipping content, so I’ve tried to make pages as light as possible without gzipping.

To use Tweete, simply login with your twitter login details and away you go; no need to create an account or maintain another password.

Currently the following features are implemented in Tweete:

  • Send updates
  • User & friends timeline (with pagination)
  • View replies
  • View direct messages & send direct messages
  • Pagination for direct messages & replies
  • Mirrored Twitter URL structure
  • User profiles
  • Follow & Unfollow users
  • API Limit handling

The following features are planned:

  • Delete tweets & direct messages

And the following may or may not be implemented:

  • Customize css colours from twitter account settings

If anyone has any suggestions, feel free to contact me with them (or leave a ticket at the Tweete Trac page) and I’ll see what I can do :)

For those of you who are interested in implementation details; I used the Kohana PHP Framework. Kohana is designed from ground up as a lightweight secure php framework for rapid application development. I have had a look at a number of frameworks for php, and in my opinion, is the most easy and logical to use.

09-08-08 at 23:51:42
Inaugural BarCampGoldCoast was a success!

BarCamps are exploding around the world these days with new events and locations popping up all over the place. Australia is no exception! The inaugural BarCamp Gold Coast took place today at Griffith University on the Gold Coast and it was a complete success (Many thanks to Steve Dalton for organising the entire day). I won’t rattle on about what BarCamp is etc as I have already done that with my last post about BarCampBrisbane.

Topics for the day ranged from Incorporating companies through to twisted programming in python all the way to reflections in Java; a pretty broad spectrum of topics by any means.

For the first time, I decided to participate more actively and give a presentation of my own. I decided to talk about AJAX Pushing Techniques (a topic very close to my heart) as most people don’t realise there are different ways that AJAX communicates; they simply group them all together under one umbrella called titled AJAX. I talked about three common methods of AJAX communication: polling, long-polling(comet) and pushing, and the consequences/considerations one needs to take when implementing each of them. For more information, you can download my powerpoint presentation from here. If people are interested, I’ll post my code samples here too, but unfortunately they could be a little tricky to get working if you aren’t familiar with named pipes as the GPS simulator server relies on them.
Based on feedback from people after the presentation, I think a lot of people enjoyed the topic as it is very relevant at the moment. In particular, people showed great interest in the section on multipart pushing, perhaps something to keep an eye on in the future.

As with every BarCamp I have been to, the presentations come second to the networking opportunities provided by the ‘unorganised nature’ of BarCamp. If you aren’t very technical, or don’t really understand something about IT, BarCamp is still for you! You don’t even need to be technically minded to gain something from attending BarCamp, and if you have thought about going but never bothered, I strongly encourage you to attend the next one as you only have something to gain.

If you are interested in the twitter hashtags for the day, you can check them out here: #barcampgc and #bcgc

If you want to check flickr pics from the day, check them out here and here or for the twitpic stream, check them out here

Here are some links to other peoples blog posts about the day:

Steve Dalton
Michael Rees
Matt Hooper
Des Walsh

05-07-08 at 23:15:54
PS3 Disc Error

Well, I booted up my PS3 today to give my brand new copy of Prologue a go. I inserted the disc into the Playstation, but it never appeared in the crossbar. All I can see is the little loading icon in the top right. I have tried a few different games; ones which I know work, but no luck. It seems my ps3’s laser has burnt out or something. Nevertheless, I have an extended warrenty on it, so no big drama other than the massive inconvenience it is causing. :(

I was initially suspect about it last night when I tried to resume playing Burnout Paradise, but wasn’t able to due to an error message on screen saying “Disc Read Error”. I just turned the PS3 off and went to bed, but waking up this morning I see that its a larger problem than first anticipated.

It seems like it is a fairly common problem with the PS. Anyone else had this problem with their PS3?

EDIT:  I called Sony to ask what to do. Basically they said to send it to them (they pay the shipping), and then they send me one back. Great customer support! It’s nice dealing with companies like this.  My PS3 is out of warranty too!

27-04-08 at 13:15:37
Gold Coast Twitter Underground Brigade (GCTUB) 1!

There are a lot of twitter meet ups around the world these days, but unfortunately there isn’t one on the Gold Coast (Australia); so Kahunagirl and I decided to organize the first Gold Coast Twitter Underground Brigade (GCTUB) for our lovely city. We will be having the first meet up at an awesome new put in Varsity Lakes called Hotel CBD. The details are as follows:

Location: Hotel CBD, in the lounge bar area (next to the bistro).
Address: Cnr Lake Street and Varsity Parade, Varsity Lakes, QLD, 4227
Date: Wednesday, April 2, 2008
Time: 7:30pm to around 8:30pm
Dress Code: No singlets/thongs/shorts (not my decision, the pub has a dress code)
Age: 18+ (the next one will be more underage friendly)
Everyone is welcome to attend, if you wish to get more up to date updates, follow either myself or kahunagirl on twitter. If you don’t use twitter, then you can join the facebook event. I will upload photos after the event to my flickr page and this blog post.

Don’t be shy, it is a great opportunity to network with like minded individuals. Hope to see you there!

Melbourne Formula 1 Grand Prix

Last week my father and I went to the first round of the  2008 Formula 1 Grand Prix season in Melbourne.  I had a fantastic time watching the race and checking out all the off track activities. There was historic and modern car exhibitions  in the middle paddock which had cars such as the Bugatti Veyron, old Brabbham cars and a lot of others.

As they are planning to move the Formula 1 from Melbourne to another location, it was a great experience to see it live. I think the last race at Melbourne will be in 2010, and I’d definitely recommend it to anyone who follows F1, but hasn’t been to a race

I have posted my pictures to flickr, but you can also check some of the images out below.

22-03-08 at 15:58:27
jQuery fadeIn/fadeOut IE cleartype glitch

While using the jQuery  javascript library today at work, I noticed a glitch under IE7. When fading a html node with the .fadeIn() and .fadeOut() functions in jQuery, IE drops the windows Cleartype rendering; which results in very ugly text. This problem appears to be very common, but no one has a nice solution for the problem.

The most common way to solve this problem is by removing the filter CSS attribute. In normal javascript, it would look like this:

document.getElementById('node').style.removeAttribute('filter');

and in jQuery, it would look like this:

$('#node').fadeOut('slow', function() {
   this.style.removeAttribute('filter');
});

This means that every single time we want to fade an element, we need to remove the filter attribute, which makes our code look messy.

A simple, more elegant solution would be to wrap the .fadeIn() and .fadeOut() functions with a custom function via the plugin interface of jQuery. The code would be exactly the same, but instead of directly calling the fade functions, we call the wrapper. Like so:

$('#node').customFadeOut('slow', function() { 
   //no more fiddling with attributes here
});

So, how do you get this working? Just include the following code after you include the jQuery library for the added functionality.

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);
03-03-08 at 21:33:27
A little piece of gold

Just thought I’d take the time to share a little piece of gold on the internet. It is my favourite comic strip and it can be found on a site called xkcd. Enjoy.

Exploits of a Mom
Image sourced from: http://xkcd.com/327/

Being a web developer, I deal with SQL on a daily basis, so I find this comic particularly hilarious. I hope you do too.

26-02-08 at 21:49:36
Google Summer of Code 2008 Announced!

Well, its that time of the year again; Google has announced Summer of Code 2008! I’ve always wanted to take part, but I never seem to have the time. Maybe 2008 is the year for me?

Is anyone else interested in participating in SOC2008?

26-02-08 at 14:35:08
Newer Posts »
Advertisment
calendar
contact
  • Email: bmn _at_ bmn . name
  • GTalk/Jabber: bmn _at_ bmn . name
  • Skype: bennovakovic
  • ICQ: 15458495
  • PSN: xaez
  • Flickr: bennovakovic
  • Twitter: bmn
  • del.icio.us: xaez
  • last.fm: xaez
  • Facebook: Ben Novakovic
  • FeedEachOther: bmn