Books that are my Developer Mantra

I can’t put it any simpler: buy and read those 2 books ASAP. Getting Real Rework This is proper stuff. This is stuff that translates into words what you, THE DEVELOPER, would like to have in your daily work life. And probably the reason for which having a pet project, something where you set the rules, helps remaining sane, and sometimes to dream that, one day, you will be on your own.

May 3, 2010 Â· 1 min Â· 72 words

Job's (a bit) wrong

This is a set of commets to some of the asserts made by Steve Jobs in his Thoughts on Flash. Safari has just ~5.5% of web users share […] Apple even creates open standards for the web. For example, Apple began with a small open source project and created WebKit, a complete open-source HTML5 rendering engine that is the heart of the Safari web browser used in all our products. WebKit has been widely adopted. Google uses it for Android’s browser, Palm uses it, Nokia uses it, and RIM (Blackberry) has announced they will use it too. Almost every smartphone web browser other than Microsoft’s uses WebKit. By making its WebKit technology open, Apple has set the standard for mobile web browsers. […] Ehm, what about Netscape Gecko? It’s not just Firefox and it’s share of web users, much larger than the one of Safari, but also the fact that the Mozilla Foundation is very much involved in building (W3C) standards like HTML5 et similia. I can see that you used the word “Almost”, but that’s not a good start: Steve, let’s try to be more fair here. ...

May 2, 2010 Â· 5 min Â· 1043 words

3 o'clock javascript

I was writing some code to react at a textarea.onKeyUp. I take the size of the current textarea.val().length, update an element and do some other stuff. yawn The first version of the code looked like: 1 2 3 4 $('#message').keyup(function(e){ $('#chars_num').html( new_len ); $('#sms_num').html( Math.floor($('#message').val().length / 161) +1) ); }); Working good, but was clearly slow: every keystroke was “giving back the cursor” too slowly for a fast typer like me. I went to take a look at twitter, and their text box was WAY FASTER. ...

March 28, 2010 Â· 1 min Â· 201 words

Why iPhone still ruleZ

I’m going to make a simple point. And because people that know me think I’m a “unfair-Google-aficionado-that-doesn’t-see-how-evil-Google-is”, I’m going to use Android as victim here. iPhone ruleZ Other OS? I’m not even taking into consideration old stuff like Symbian: is just too easy to trash it now-days (Qt is a whole different story though). ...

February 17, 2010 Â· 3 min Â· 589 words

Binary Tree Rebuilder

Imagine you have a Binary Tree, with those characteristics: * Nodes do not respect any order relation - In other words: it's <strong>not</strong> a [Binary Search Tree](http://en.wikipedia.org/wiki/Binary_search_tree) of any kind * Every node appears <em>once and only once</em> within the tree A nice Binary Tree Then, your little brother passes by your desk and, to upset you, deletes the tree from your computer memory/HD (yeah, I know, I’m pathetic at inventing hypothetical situations :-P ). Fortunately though, you previously did a Pre-Order and an In-Order visit of your tree, and stored the result in an 2 nice array. Can you rebuild the original tree structure out of this 2 array? How are you going to rebuild it? Yes, you can! (Sorry, I couldn't resist). And it's quite easy as well. What you have to do, is the following: Take the first element of the PreOrder Array and use it as root of a new tree Find the position of this New Node in the InOrder Array, scanning it from 0 to n-1 (n is the number of Nodes) IF next element in the PreOrder Array is on the left of the New Node in the InOrder array: call RECURSIVELY this procedure, this time taking into account the portion of InOrder array that goes from 0 to the position of the New Node in the InOrder Array -1. IF next element in the PreOrder Array is on the right of the New Node in the InOrder array: call RECURSIVELY this procedure, this time taking into account the portion of InOrder array that goes from the position of the New Node in the InOrder Array +1 to n-1. Return the New Node By the way, this doesn’t work. To fix it we should be more generic, specifying things a little bit better. Things like: * Every recursive calls takes into account a portion of the InOrder array; in the case of the first call it's the entire array * There is going to be as much recursive calls as the number of elements in the PreOrder array Of course, is a tree what we are talking about here: recursion is a MUST. ...

February 5, 2010 Â· 5 min Â· 862 words

Serverless chat to reduce office distance

This idea comes out for an old university-time idea: to write a serverless chat application. Of course, I’m aware of the complications and the problems that using Broadcasting could create, so this problems would be took in consideration by design. But why now? I was thinking of a way to reduce the “office distances”: making easy to connect with a person who works in your own office. I know, it sounds a bit “creepy” to depend on an application to do that. After all you could just stand up and go to the colleague’s desk. And that’s what I’d normally do: nothing impossible. ...

January 31, 2010 Â· 3 min Â· 470 words

iPad Simulator in Video and Comments

I would have just posted it on Twitter, but I have some comments about this video. One of the first video of the iPad Simulator Watch it in Full screen at 720p: it help “feeling” the proportions used by Apple in the UI It clarify how it does execute iPhone apps: they most probably implement the iPhone API as is: indeed even the Keyboard that you get in an iPhone application is the same (no super large/super cool keyboard of the iPad ...

January 30, 2010 Â· 2 min Â· 342 words

Prime Numbers Generator

I believe I don’t have to describe what primes are, what are their properties and what not. This post is more a tribute to geek-ness of 2 friends-and-colleagues (@lucabox) that have fun thinking of algorithms to solve stupid (or less stupid), and always useless problems ;-) . Optimus Prime :-P - yeah yeah, a stupid joke Briefing This code is based on the assumption that we want to generate very very large primes, so it uses unsigned long long to store the values, instead of classical unsigned int. Live with that. ...

January 23, 2010 Â· 4 min Â· 760 words

"Bidirectionally multiplied" array

Another small problem before I go to sleep tonight: There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n). ...

January 22, 2010 Â· 2 min Â· 281 words

Use Backtracking to print all Subsets

I’m “studying” this algorithmic technique: Backtracking. This is an algorithmic approach to problem solution that I trust every good Computer Scientist already uses; but taking a good theo-practical look at it is something better. A Backtracking Tree I believe you can find enough informations about it online (the 2 links I provided are more than enough), so I’ll go straight to the problem. Problem definition Given an integer n, and the set S = { 1 … n }, calculate (print) all the possible subsets of S. For example, for n = 1, all the possible subsets are { 1 } and { } (empty set). For n = 2, all the possible subsets are: { 1 2 } { 1 } { 2 } { }. In general, for the set made of the first n Integers, the number of possible subsets is 2n. ...

January 22, 2010 Â· 4 min Â· 833 words