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.



Ingredients:

  • 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

Preparation:

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

Sunday, September 11, 2011

How I like my Thunderbird

I've been using Evolution for many years and very few criticisms. Until I bought a netbook and discovered that Evolution has a minimal width larger than the 600px of my screen resolution. So I switched to Thunderbird but I had to tinker a bit with it before having it behave like I want. This is all the steps it took:
  1. Install the Lightning Calendar extension.
  2. Install the Provider for Google Calendar extension to allow synchronization between Lightning Calendar and Google calendar.
  3. Sync my Google calendar with Thunderbird. File>New calendar, select 'from network', Google, enter the calendar URI.
  4. Install the Zindus extension to synch Thunderbird with my Gmail address book.
  5. Install all the extensions to have Thunderbird properly integrated with Ubuntu Unity: Global Menu Bar Integration, Messaging Menu Integration and Unity Launcher Integration. Search for 'unity' in the Get Add-ons page.
  6. Install the Spanish and French language packs. Save each archive and install it manually through the Get Add-ons page.
  7. Install the CompactHeader extension to reduce the size eaten up by the headers' bar.
  8. Change the time locale to Great Britain. Thunderbird is using the Linux LC_TIME locale to format the dates and time. I like my Ubuntu in American English but I like my dates to be formatted according to the British format. It's enough to add LC_TIME="en_GB.UTF-8" in the /etc/environment file (source).
  9. Install the ConfigDate extension to fine tune the date length.
  10. Change the default download policy of the pictures in html emails. Use the config editor to set the "mailnews.message_display.disable_remote_image" value to false. Thunderbird will now download the pictures without asking permission (source).