Planet ubuntu-uk

This page contains feeds from ubuntu-uk member's blogs

For more info please see the planet wiki page The Feed url for this planet is http://planet.ubuntu-uk.org/atom.xml .

The views expressed here do not represent the views of ubuntu, canonical or ubuntu-uk

July 03, 2009

Stuart Langridge's face
Stuart Langridge
(aquarius)

Not blocking the UI in tight JavaScript loops

Everyone’s written a JavaScript loop that just loops over all the {LIs, links, divs} on a page*, and it’s pretty standard. Something like

var lis = document.getElementsByTagName("li");
for (var i=0; i<lis.length; i++) { // yes this could be more efficient, don't care
  // do something here to lis[i]
};

or, if you’re using jQuery:

$("li").each(function() {
  // do something here to this
});

This is problematic if there are, say, 2000 LI elements on the page, and what you’re doing in the loop is semi-intensive (imagine you’re creating a couple of extra elements to append to each of those LIs, or something like that). The reason this is a problem is that JavaScript is single-threaded. A tight loop like this hangs the browser until it’s finished, you get the “this script has been running for a long time” dialog, and the user interface doesn’t update while you’re in this kind of loop. You might think: aha, this will take a long time, so I’ll have some sort of a progress monitor thing:

var lis = document.getElementsByTagName("li");
for (var i=0; i<lis.length; i++) { // yes this could be more efficient, don't care
  // do something here to lis[i]
  progressMonitor.innerHTML = "processing list item " + i; // fail
};

but that doesn’t work. What happens is that the browser freezes until the loop finishes. Annoying, but there it is.

One approach to getting around this is with timeouts rather than a for loop.

var lis = document.getElementsByTagName("li");
var counter = 0;
function doWork() {
  // do something here to lis[i]
  counter += 1;
  progressMonitor.innerHTML = "processing list item " + counter;
  if (counter < lis.length) {
    setTimeout(doWork, 1);
  }
};
setTimeout(doWork, 1);

so you move the bit of work you need to do into a function, and that function re-schedules itself repeatedly, using setTimeout. This time, your user interface will indeed update, and your progress monitor will show where you’re up to. There are a couple of caveats with this: it’ll take a bit longer, and you’re no longer guaranteed to have things processed in the order you expect, but they’re minor issues.

For doing this in jQuery, a tiny plugin:

jQuery.eachCallback = function(arr, process, callback) {
    var cnt = 0;
    function work() {
        var item = arr[cnt];
        process.apply(item);
        callback.apply(item, [cnt]);
        cnt += 1;
        if (cnt < arr.length) {
            setTimeout(work, 1);
        }
    }
    setTimeout(work, 1);
};
jQuery.fn.eachCallback = function(process, callback) {
    var cnt = 0;
    var jq = this;
    function work() {
        var item = jq.get(cnt);
        process.apply(item);
        callback.apply(item, [cnt]);
        cnt += 1;
        if (cnt < jq.length) {
            setTimeout(work, 1);
        }
    }
    setTimeout(work, 1);
};

and now you can do

$.eachCallback(someArray, function() {
  // "this" is the array item, just like $.each
}, function(loopcount) {
  // here you get to do some UI updating
  // loopcount is how far into the loop you are
});

$("li").eachCallback(function() {
  // do something to this
}, function(loopcount) {
  // update the UI
});

Not always a useful technique, but when you need it, you need it.

July 02, 2009

Alan Pope's face
Alan Pope
(popey)

UDS Karmic Videos and HTML5 Goodness

I noticed that the videos from the most recent Ubuntu Developer Summit are now online, and thought I’d have a play with the new embedded HTML5 video stuff in Firefox 3.5.

Rather than view all the videos by downloading them individually I thought I’d make a page where I can view them all sequentially.

Here is the html I threw together. Guess it will look rubbish in anything but Firefox 3.5. Of course that’s no guarantee it will look any good in Firefox 3.5. Just, y’know, you’ll see the videos :)

Steve Garton's face
Steve Garton
(sheepeatingtaz)

Twitter Updates for 2009-07-02

  • http://twitpic.com/8yrx6 I say mummy, Hannah says <grin> #
  • Quick #lazytweet – should I watch Superman returns or Mock the week? #
  • did 20 press ups and 20 sit ups yesterday. Today, I need a wheelchair and a stairlift. #
  • Hugs #python for making things easier #
  • Has attained a whole new level of awesome #

Powered by Twitter Tools.

Steve Garton's face
Steve Garton
(sheepeatingtaz)

Twitter Updates for 2009-07-02

  • http://twitpic.com/8yrx6 I say mummy, Hannah says <grin> #
  • Quick #lazytweet – should I watch Superman returns or Mock the week? #
  • did 20 press ups and 20 sit ups yesterday. Today, I need a wheelchair and a stairlift. #
  • Hugs #python for making things easier #
  • Has attained a whole new level of awesome #

Powered by Twitter Tools.

Josh Holland's face
Josh Holland
(dutchie)

Update on xkcdrss.py

Remember that little script I wrote to pull the latest comic from xkcd? Well, I actually got around to fixing up the readability and removing the horrible one liner.

Firstly, I moved from xml.dom.minidom to Mark Pilgrim’s (whose book Dive Into Python taught me the language) Universal Feed Parser and broke the parsing of the script up into a few more lines. It now looks much nicer, and will be considerably easier to maintain.

Also, I added an optional command line argument that specifies where to save the picture, defaulting to ./xkcd-today.png.

I won’t bother posting it inline, but you can find it at http://joshh.co.uk/stuff/xkcdrss.py.

July 01, 2009

Simos Xenitellis's face
Simos Xenitellis
(simosx)

guadec, gsoc l10n-el, ellak-conf

guadec

I am attending GUADEC this year, thanks to the sponsorship by the GNOME Foundation!

sponsored-badge-shadow

I am organising the GNOME Localisation BoF, which takes place on Friday, 10th July, 2009, at 17:00. I am also having a session on the GNOME translator command line tool gnome-i18n-manage-vcs on the same day at 15:00.

gsoc

A few months ago, there was a program in Greece, along the lines of the Google Summer of Code, to help Greek developers in FLOSS projects. The program was organised by EELLAK, a Greek non-profit, composed of 25 institutions of the tertiary education and research centres. As it took place during the spring, it was nicknamed Greek Spring of Code (gsoc).

Apart from developing software, the program had a localisation angle, and we applied for the localisation of GNOME 2.26 to the Greek language. In practice, this meant that we had to lift the documentation translations from 32% to 100%, complete the remaining UI translations.

GNOME-226-el

We achieved the goal ;-) .

Many contributors helped in this effort; Jennie Petoumenou (also co-organiser in the effort), Marios Zindilis, Fotis Tsamis, Kostas Papadimas, Nikos Charonitakis, Sterios Prosiniklis, Giannis Katsampiris, Michalis Kotsarinis, Vasilis Kontogiannis and Socratis Vavilis.The overall task was difficult, and our team did an amazing task to complete the translations on time. Thank you all, and especially Jennie and Marios for undertaking huge chunks of the translation effort for this release.

Here are the GNOME EL 2.26 deliverables in HTML, PDF.

ellak-conf

The fourth Greek FOSS (ELLAK) conference took place in Athens on the 19-20th June 2009.

p6190288 by Elias Chrysoheris.

We had our annual localisation meetup!

I organised a workshop on git, with a focus on how to use when starting into software development. There was emphasis on using github.com to host and manage the development. In addition, services such as github.com allow to cooperate during the development, making programming a more social and interesting task.

Finally, there was a presentation of the Greek GNOME team efforts for the last year.

No comment

no picture
Phil Bull

Removing the audio track from a video file, and vice versa

To remove the audio track from an Ogg video (.ogv), leaving only the video behind, install oggz-tools and run the following command:

oggzrip -c theora input.ogv > output.ogv


Likewise, to extract the audio track from an Ogg video:

oggzrip -c vorbis input.ogv > output.ogg


Ogg is a container format, which means that it can contain several files of different types and play them at the same time. Vorbis is an audio format and Theora is a video format, so when you watch an Ogg video, it is playing back the Theora movie track at the same time as the Vorbis audio track.

The oggzrip command can be used to extract single tracks from the Ogg container. The "-c" option allows you to choose which track to extract. In the first example, "theora" is the chosen track, so only the video (without sound) is extracted and output to the file "output.ogv". In the second example, "vorbis" is the chosen track, so only the audio is extracted.

These instructions were painfully arrived at on Ubuntu Jaunty (9.04). See the oggzrip man page for more information.
Alan Lord's face
Alan Lord
(TheOpenSourcerer)

How to run Firefox 3.5 on Ubuntu 9.04 Jaunty Jackalope

Mozilla Firefox 3.5 was released yesterday. It isn’t (at the time of writing this) available for install through the repos on Ubuntu Jaunty. I guess it will be backported at some stage but should you want to play about with it, here is how I did it so as not to (hopefully) break anything else… [Note: you should probably back up your profile directory before going any further. Something like this should do it: cp -a ~/.mozilla ~/firefox-3.0-backup]

I downloaded the Linux tarball and unpacked it. I moved this directory (called firefox) to my local bin dir:

mv firefox ~/bin/firefox-3.5

This command assumes you are in the same directory as the tarball you just extracted and have a local bin directory. If not just do mkdir ~/bin first.

Then I started the current Firefox Profile Manager and created a new profile just for 3.5 to test (I didn’t want any conflicts or updates to my existing firefox 3 add-ons). To check that you are using the right path for the existing installed Firefox you can do a command like which -a firefox which will give you the full path to any firefox executables on your system and in your path.:

/usr/bin/firefox -no-remote -ProfileManager

Follow the Profile Manager dialogues to create a new profile – I called mine 3.5 amazingly. Exit the profile manager (don’t start firefox or else you’ll end up with the existing firefox also using the 3.5 profile).

Now you can run the 3.5 version of Firefox by typing the following command:

~/bin/firefox-3.5/firefox -no-remote -P 3.5

The -no-remote switch ensures that we start a clean instance of FF from these commands. If you already have an instance of FF running and you do not use this switch, you’ll get another window tied to the same, already running, firefox process. This also affects trying to start firefox remotely over X as I discovered quite some time ago.

I have since created a launcher on the top panel to start FF3.5.

It seems to work OK and feels incredibly fast at loading pages, but trying to run anything that needs flash causes it to die horribly.

So although this isn’t perfect, it was a reasonably safe way to test and just try it out. YMMV of course and I really think we’d all probably be better just waiting for one of the MOTU “Gods” to deliver a 3.5 backport for Jaunty. :-)

Paul Mellors's face
Paul Mellors
(MooDoo)

To much information…..

I’ve just surprised myself with the amount of email addresses i currently have, i think i need to consolidate them and have one, currently i have

hotmail
gmail
yahoo
own hosted email [about 4 here]

Do i really need this many email addresses :) I think it’s time to close accounts :)

It’s a shame apps i use are linked to these, flickr for instance is linked to my yahoo account….picasa is linked to my gmail, is it time to go totally self hosted?

I’ve probably mentioned this sometime in the past so apologies if i’m repeating myself.

Related posts:

  1. Picasa – Ubuntu

Steve Garton's face
Steve Garton
(sheepeatingtaz)

Twitter Updates for 2009-07-01

  • got horrible trapped wind. without the trapped. #
  • debating whether to get breakfast, knowing full well as soon as I do, Hannah will wake up. #
  • http://twitpic.com/8xiup no daddy, no breakfast for you! #
  • Needs something to do while mother & baby do their daytime tv routine. #
  • Re-watching last week's top gear, Lisa spotted The Stig photocopying his head! :-D #

Powered by Twitter Tools.

Steve Garton's face
Steve Garton
(sheepeatingtaz)

Twitter Updates for 2009-07-01

  • got horrible trapped wind. without the trapped. #
  • debating whether to get breakfast, knowing full well as soon as I do, Hannah will wake up. #
  • http://twitpic.com/8xiup no daddy, no breakfast for you! #
  • Needs something to do while mother & baby do their daytime tv routine. #
  • Re-watching last week's top gear, Lisa spotted The Stig photocopying his head! :-D #

Powered by Twitter Tools.

June 30, 2009

no picture
Chris Rowson
(leftcase)

“Email on Three” Push email using SEVEN.

I’ve just installed the ‘email on three’ application onto my Nokia e71. It seems to be a rebranded version of SEVEN; a push email solution for various mobile devices including Symbian based mobile phones.

So far it seems to be pretty good, and although there are a few reports on the ‘tinterweb indicating poor battery life, later comments suggest that this has got better with recent updates to the software.

All of which leads me to the question of whether or not ‘email on three’ uses SMS messages to trigger email synchronisation or whether it keeps an data connection open back to three’s NOC?

Anyone happen to know?

Jonathan Riddell's face
Jonathan Riddell
(Riddell)

Tutorials Day Logs

Tutorials Day rocked and logs are now available for those who missed it. Talks covered Ruby, Amarok Scripting, Artwork, Packaging and Kubuntu Karmic.

Andy Loughran's face
Andy Loughran
(andylockran)

Preparations for Hop Farm Festival

I’m looking forward to this weekend more than most, after I managed to bag tickets for the Hop Farm Festival for an ultimate bargain!

SATURDAY: THE FRATELLIS, PIGEON DETECTIVES, THE VIEW, ASH, ECHO AND THE BUNNYMEN,  FLORENCE AND THE MACHINE, NOAH AND THE WHALE, HOWLING BELLS,  ETIENNE DE CRECY LIVE, AJAX, DR. LEKTROLUV, D.I.M, DADA LIFE, DATAROCK, WHITEY (DJ SET), JAPE, FC20, THE SUNSHINE UNDERGROUND, WHITE DENIM, BELL X 1, THE JOY FORMIDABLE, THE TWILIGHT SAD, LET’S WRESTLE, THE GOOD THE BAD.

SUNDAY: PAUL WELLER, EDITORS, DOVES, SUPER FURRY ANIMALS, THE TWANG, MYSTERY JETS, LADYHAWKE, THE RIFLES, THAT PETROL EMOTION,  2MANYDJS, SCRATCH PERVERTS, KISSY SELL OUT, ALEX GOPHER, METRONOMY, HEARTBREAK, BURN THE NEGATIVE, RARELY SEEN ABOVE GROUND, BRITISH SEA POWER, THE RUMBLE STRIPS, 65 DAYS OF STATIC, DANANANANAYKROYD, FIGHT LIKE APES, THE CHAPMAN FAMILY, SERGEANT, EIGHT LEGS.

Awesome line-up.  Got everything required for the camping weekend away.  It’s going to be lovely.

Which bands do you recommend I try and see?  If you’re going to be there, say hi!

Steve Garton's face
Steve Garton
(sheepeatingtaz)

Twitter Updates for 2009-06-30

  • now needs a new network card too. Looks like frankenstein's monster is dying :-( #
  • thinking about going to sit in the fridge #

Powered by Twitter Tools.