Archive for May, 2008

The timeline for dojo meetup Berlin

The plan for May 31st, 2008 is

15:00 meet at Weltzeituhr, as mentioned on upcoming, more info and a pic see here. When you are on Alexanderplatz you should find this clock pretty quickly.

19:00 - 22:00 we will be in Las Olas
and afterwards go to some bar, club, whatever we find, if you didn’t make it to join us until 22:00 your chances are only to search all of Berlin’s nightlife. Or catch one of us in the IRC channel #dojo before and get a mobile phone number (our nicks are klipstein, nonken, mccain).

And I will have a couple of T-Shirts with me, so be prepared to get undressed :-)

see you

Comments (3)

Dojo + Zend Framework

Yeah, this is really really good news, for both worlds. I was following Zend Framework loosely but from a lot of friends in this scene I have heard that it is the rising star and quasi industry standard of PHP frameworks. And now the logical next step to join forces with dojo is just right. For those that have doubts, you can use any other JavaScript toolkit with it too, but why would you want :-).
Looking forward into the great future of server and client interaction!

Comments (1)

T-Shirts for dojo.meetup() in Berlin!

dojo shirt (front)If you are around Berlin May 31st 2008 (as already mentioned a couple of times), consider joining us dojo folks form Europe to just informally get together and chat about the latest and greatest while discovering Berlin and it’s nightlife (the upcoming link). And if you want to be well dressed, we can help you too!

dojo shirt (back)
The shirts are available with the Berlin-specific back-side, which says

dojo.meetup(
    "Berlin",
    "May 31, 2008"
);
dojo.beer();


And we have checked it a couple of times, there should be no errors in there :-).

You can buy

The shirts are really good quality as the print is too! They will last for a while, you can be sure.
And don’t forget to be there, in Berlin! We are looking forward to seeing you.
For all those coming to Berlin, I will have a couple with me.

Comments (1)

JavaScript: Sort object by a value

Actually the headline is not really what I want to say :-). But I don’t know any better yet.
I just want to write down how I solved sorting the following:

>>> var maxSpeed = {car:300, bike:60, motorbike:200, airplane:1000,
    helicopter:400, rocket:8*60*60}

This is a list of vehicles with their (approx.) max speeds. And now, I would like a list of the vehicles sorted by their max speed. This looks sooo easy, and actually it is :-). You just have to know how.
Look at this:

>>> var sortable = [];
>>> for (var vehicle in maxSpeed)
      sortable.push([vehicle, maxSpeed[vehicle]])
>>> sortable.sort(function(a, b) {return a[1] - b[1]})
[["bike", 60], ["motorbike", 200], ["car", 300],
["helicopter", 400], ["airplane", 1000], ["rocket", 28800]]

Since the sort function takes an extra argument, that allows to do your custom comparison we simply make sure that the right stuff gets compared, which is our speed. Unfortunately we can not sort the object directly, it has to be an array for doing so. But you can now convert it back, or just extract the vehicles, like so:

>>> dojo.require("dojox.lang.functional")
>>> vehiclesSortedBySpeed =
        dojox.lang.functional.map(sortable, function(i) {return i[0]})
["bike", "motorbike", "car", "helicopter", "airplane", "rocket"]

Didn’t I say it was easy?

Comments (8)

JavaScript: Remove element from Array

[UPDATE] Thanks to Joe and others hinting me to the danger of purely using indexOf() without a check for -1. Added it in the last example.

I mean it’s not the first time I am doing it, but it happens always again that I have to look up how exactly it works. And every time I know it is very easy.
So here is how to remove an element from an array, mainly for my poor brain, so it doesn’t have to remember anymore. Though I know, now that I wrote it down I will never forget it again.

DON’T
Unfortunately the most obvioous solution leaves a “hole” in the array :-(.

>>> var list = [4,5,6];
>>> delete list[1];
true
>>> list
[4, undefined, 6]

Sad, but understandable.

DO
So do it right and use splice().

>>> var list = [4,5,6];
>>> list.splice(1, 1); // Remove one element, returns the removed ones.
[5]
>>> list
[4, 6]

Useful DO
Actually, what I mostly need is: remove a certain value from an array.
I.e. I have some list of visible IDs and I want to remove one because it’s not visible anymore. So just extend the above example a bit.

>>> var visibleIds = [4,5,6];
>>> var idx = visibleIds.indexOf(5); // Find the index
>>> if(idx!=-1) visibleIds.splice(idx, 1); // Remove it if really found!
[5]
>>> visibleIds
[4, 6]

I hope I didn’t bore anyone with that :-)

Comments (58)

Dojo.cast()

Now there is already episode 2 out of the dojo podcast “from the guys” (I like when Pete says that).
There we are trying to discuss common topics, interesting things about and around dojo. If you want to join us, have comments, an interesting story to tell or alikes, just let us know and mail us at wolfram@dojotoolkit.org or contact us in the irc channel #dojo (just ping one of us: phiggins, nonken or mccain).
Have fun listening …

Comments