Monday, May 20, 2013

A message to god believers

A lot of christians and other god believers are active through their faith in helping other people. Running or giving money to charities, using their free time to help disadvantaged people... that's all very laudable. But I'm asking you, if you really believe that you will go up to a place where you'll spend your time having picnics with Bambi if you die having being a good citizen of the Earth, then why postpone the time of your death? Maximize you chances to heaven and minimize the waiting by doing life threatening heroic actions of goodness!

There are innumerable opportunities to put this precept in action. For instance, go to conflict zones and help civilians. There are for sure many places where such an attitude would be useful. Wikipedia maintains a list of such ongoing conflict zones. Pick up a destination and buy a one way ticket.
A few people used to do that during the history of christianity, dedicated nuns and priests. But what about the other 99.99% of others? Well, they buy SUVs to lower their chance of dying in a car crash and are too busy working to pay the loans to help other people.
Take example on the suicidal bombers. They are truly dedicated to their faith and beliefs. It is too bad they are busy killing people instead of saving lives. But by risking your life to save other human beings, YOU can prove than being a fundamentalist is not always a bad thing.
Trust me, it's a win-win situation here. If you save lives, you increase you chances of being welcomed in the kingdom of Jesus and Donald Duck. And if you've got a family and are afraid of leaving it behind you, don't worry, god will take care of it.

So what about me, do I help my fellow man like I'm advocating in this post? Well no. I don't believe in god as a start, which makes me amoral. So as I will end up in hell anyway why bother?

Monday, January 28, 2013

butternut squash soup

This soup usually comes in many variants, depending on the geographic location. This recipe comes from the reverse-engineering of a soup I used to order in a Catalan restaurant in the heart of Barcelona, to which I added my personal touch.


  • 1 butternut squash (~1kg)
  • 1 onion (yellow)
  • 1 cube vegetable stock
  • 1/4 lemon juice (or according to taste)
  • 1 tea spoon curcuma
  • paprika to taste
  • double cream


Skin the onion, cut in small chunks and brown in a pan on light fire with olive oil.
Meanwhile, skin the squash and cut in big chunks. When the onions start to have a nice color, add the squash and cook until it starts to get tender. Cover with water, add the stock and cook until soft.
When cooked, add the lemon juice, the curcuma and paprika, and mix with a plunging mixer until perfectly smooth.

After serving, pour one table spoon of double cream in each bowl and sprinkle with some fresh coriander leaves.

Thursday, November 29, 2012

The many ways to get a memory leak in PHP

I wrote this crawler whose job is to check 24/7 a bunch of html pages. The crawler is run by cron. At each run, it check what pages need to be checked, scrap them, update the DB, and exits.
The application crawls URLs in parallel using the multi_exec feature of CURL. This allows to scale up the crawling capacity as the number of URLs to refresh every day increases by increasing the number of pages crawled in parallel.
But it had a massive memory leak, preventing it to actually scale much.

The function memory_get_usage() give how much memory a PHP process is using. However, it turned out the be quite difficult to solve the issue because the application had several leaks, 3 actually. Hereafter I list the cause of each of them and give the solution along with some references.

1rst leak:
The crawler is a Symfony task. Symfony tasks can use 2 types of configuration objects, sfProjectConfiguration and sfApplicationConfiguration. The later one by default activates Symfony debug mode. The debug mode turns out to have Doctrine keeps a copy of every query sent to the database, as mentioned in this thread. If you do need to use a sfApplicationConfiguration, you can turn off the debug mode by adding sfConfig::set('sf_debug', false) at the start of your script, as mentioned in this other thread.

2nd leak:
The crawler uses DOM and xpath to extract data from the html pages. Using lib_xml_use_internal_errors(true) suppresses error output for badly formed HTML but builds a continuous log of errors. The solution is to call libxml_clear_errors() after each DOMDocument creation, as mentioned in that thread.

3rd leak:
PHP garbage collection used to have a bug with circular references that has supposedly been corrected since version 5.3. Doctrine hydrated objects often have circular references and weren't properly disposed by the garbage collector. On way to solve that with PHP < 5.3 is to call $doctrine_object->free() when they are not needed any more. But what I noticed is that the circular reference bug has not been completely solved, even with PHP 5.4 (5.4.8 at the time of writing). So, do use free().

After correcting these 3 issues, my crawler is now using a constant amount of memory while crawling hundreds of URLs in parallel.

Sunday, November 27, 2011

Scrum, a new framework for modern slavery - part 1

The company I joined recently as a software developer is applying Scrum in a very rigorous way. The usage of this project management methodology has spread like fire in the startup world. Indeed, it increases significantly the productivity, specifically in software development. One can claim that it achieves this result through its innovative and intelligent project management implementation, and because its cycles of incremental change approach is particularly adapted to the startups needs. But does it do so also at the expense of the workers? Does it put a hidden cost on them?
Through a series of posts I will describe my own point of view and try to expose the Srum drawbacks and hidden pressures. The 1st post is about the Scrum planning poker.

The Scrum planning poker.
The scrum poker takes place at the beginning of every sprint. It consists in assessing the difficulty of each story in the sprint in order to create the planning. The difficulty is measured by an abstract unit of points.

Procedure: Each team member picks up a poker card with the number that represent his estimate for the story and keeps it face down. Then everybody show up their estimate by turning simultaneously their card over. If everybody has the same estimate there is an immediate consensus. If not, the team discusses until a consensus is reached.

Justification: it avoids "anchoring" (one member, usually the project manager in standard waterfall methods, biasing the thinking of the other members by giving an estimate before everybody else).

Reality: firstly, although the method claims to measure difficulty specifically to avoid giving estimates of time, in the real world people do an implicit conversion between difficulty and time. Secondly, because nobody wants to look like a slowbrain by giving a higher estimate than the others, everybody will tend to give a lower estimate than it would normally do. So, on average, the group will usually agree on a underestimated difficulty. Thirdly, because it is a consensus, it will take authority over, or at least have a higher degree of credibility than any individual subsequent estimate. Consequently, the assignee that requires more time than was estimated (unless there was an issue unforeseen during the planning) will look as a dumbass. So everybody will strive to get the task done under the estimated time/difficulty and everybody will therefore work in overdrive. To summarize, the method is using people's pride to squeeze more from them.

Hmm, maybe I should put my IT-pride aside sometimes.

Wednesday, November 9, 2011

The food industry

Have you ever heard of the Mac Donalds mutant laboratory meat legend? A meat that would be produced by growing cattle with no limbs or horns and fed through direct stomach injection? Creating this kind of urban legends doesn't require a big stretch of imagination when one knows about the practices of the modern food industry. The following 4 documentaries are showing what is sadly and frighteningly already a reality:

Food inc treats specifically about the US food industry.

We feed the world has a more international coverage.

The world according to Montsanto talks about this American company and the generically modified food in general.

Earthlings focuses specifically on animal treatment