Tuesday, October 27, 2009

Twitter must be doing some maintenance?

Haven't seen anything on status.twitter.com about it yet, but seeing the following instead of a Fail Whale is a first for me:

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Nothing a quick reload wouldn't fix (for now). But still...

Monday, October 19, 2009

Efficient checking whether IEnumerable contains data

Have you ever needed to check - in a LINQ context, or otherwise - whether an IEnumerable<T> (or plain IEnumerable) contained any elements?

Of course a check using the Count<T>() extension method to check for an element count of zero works here, but this would be... unfortunate... for sequences yielding large numbers of elements because of the O(n) linear behavior.

Maybe the following source code (or the LINQ Any() method, see comments) could be of use to you in those cases from now on:

/// <summary>Sequence contains at least 1 item?</summary>
/// <typeparam name="T">Type of elements</typeparam>
/// <param name="sequence">Sequence to check</param>
/// <returns>true/false</returns>
public static bool NotEmpty<T>(this IEnumerable<T> sequence)
  return sequence.GetEnumerator().MoveNext();

/// <summary>Sequence contains at least 1 item?</summary>
/// <param name="sequence">Sequence to check</param>
/// <returns>true/false</returns>
public static bool NotEmpty(this IEnumerable sequence)
  return sequence.GetEnumerator().MoveNext();

These extension methods check whether the given sequence contains elements or not, but does so taking only O(1) constant time. In other words: the entire sequence is not fully evaluated, but the minimal work is being done to check if the sequence contains at least one element.

Wednesday, October 14, 2009

What is wrong with me - Part 2

Remember "What is wrong with me?", the blog post from september 16th? Right now I'm pondering whether electronic gadgets are just not for me.

Yesterday evening I turned my phone off for a couple of hours. Ever since I turned it back on, it turns itself off (or hangs, or whatever) after the screen has been off for an as of yet undetermined amount of time. Then I need to remove the battery or use the receded reset switch, which turns out to be a "soft reset" (=leaving memory) and not a "hard reset" (or factory reset) after all.

This is a disaster for a phone: unless I actively keep it on and active (including the display, which burns battery like there's no tomorrow), it's a brick that I need to turn on again when I need to use it.

Right now I don't have the time to repave it, but I'm still hoping this is some kind of software glitch. If repaving this thing again doesn't remedy this symptom, I'll need to have the obviously faulty hardware replaced. In any case: just my luck.


Tuesday, October 13, 2009

So Google logos are location specific?

Today I saw something interesting when I opened the Dutch Google search page

150 jaar Max Havelaar

The ALT text said "150 jaar Max Havelaar" and this doodle is not in the official Google logo list for oktober 2009.

Does this mean that local branches of Google are actually creating localized logo doodles that are independent of the official world wide ones? And if so, what's then the use of the global logo list? Mmm...

Monday, October 12, 2009

I need to get cracking on that multitude of sensors!

Mmm, I'm already two days late: it seems Samsung has released an SDK for using the extra sensors (like accelerometer, compass, proximity, etc.) that are in their latest mobile phones. What could I do with this in my Twitter client for Windows Mobile, for instance...?

Thursday, October 1, 2009

I have a finite Erdős Number

I was browsing some old XKCD comics the other day when I stumbled upon one I couldn't really place, as I had not actually heard of Paul Erdős before.

Well, that's a problem that Wikipedia can easily solve. As I started reading up on Erdős Numbers, I noticed the Compute your Erdős Number page at the Erdős Number Project.

And lo and behold: Marc van Kreveld is listed in the list of all authors with EN ≤ 2. So, because the subject of my masters thesis got presented by him at the 3rd International Conference on GeoComputation in Bristol, I guess my Erdős Number is three. Hence the recent Twitter announcement.