Blog

  1. What Rails got Right

    While getting updated on Rails 3.1 with the latest Manning book on the subject and the thought struck me that where Rails has been the most succesful has been creating a new vocabulary. A DSL for CRUD Web applications More than just providing an MVC structure, Rails has created a DSL for Web programming, which expresses most of the common CRUD operations in a few concise lines. The con is that there is a learning curve, but in exchange you get to think in terms of these operations really fast, and begin to type code very fluidly.

  2. Designers needed

    Designers needed Sketching. Thinking out navigation paths. Planning surprises and moments of delight. We don’t need designers meaning ‘people who draw pretty pictures.’ We need people who know that some problems can’t be solved by yet more code and are ready to interview clients, draw on A3 paper, and sit down with the end users to know how they really work and figure out what’s really going to make a difference.

  3. EuroSciPy 2011

    Last month I have attended the Euroscipy conference at the École Normale in Paris. The conference is about scientific computing with Python, in particular the numpy/scipy/matplotlib stack. Performance Scientific computation is very CPU intensive; an interesting change from applications where memory and storage are the main bottlenecks. In the performance talk by Gael Varoquaux, we got to see the demonstration of a computation runnning noticeably slower when iterating through a matrix along one direction than the other.

  4. the Great JavaScript Closure Pattern explained

    Most of you will have seen it in jQuery, but also maybe in Mustache.js, or even another library:You know you need this somehow to protect the global namespace etc., But how does it work again? Follow along. It’s just a function call Yep, that’s right. You know that in JavaScript you can define anonymous functions: Well, you can also call them immediately and that's what the above code does. With that out of the way, let's concentrate on the function body and remember later to see why we would want the function to be executed.

  5. 2011 New Year resolutions

    2010 has been a great year. I have almost come to the end of my Mathematics studies. The first programming project which has made be a bit happy, concordar, has got off the ground: it’s just a toy and could be better in too many ways to name, but somehow it fits the vision of what I’d like to do more than anything else I have written before. I have become more familiar with the skilled jobs market.

  6. Hardboiled Web Design review

    Yesterday I bought a PDF of Andy Clarke's Hardboiled Web Design, and, wow. It is one of the best refreshers on HTML and CSS, and especially a practical implementation guide for HTML5 and CSS3. On top of the gorgeous illustrations. You can actually use the new <article>, <section>, <footer> elements in most recent browsers, as they in fact render elements even if they do not tecognize them. There is a workaround for Internet Explorer versions lower than 9, which involves adding a minuscule amount of JavaScript.

  7. What’s C++ like?

    Whoever said Perl looks like line noise should take a look at ‘modern’ C++. C++ is still a requirement for many engineering/number crunching jobs, so it's still worth learning. It mashes so many things together that it is like a huge revision of everything you have ever learnt about programming. The fact that you are encouraged to write your own memory mangement abstractions makes you think hard about resource management; more so than with plain C.

  8. Migrating from WordPress to Django

    This is the system I devised to move my blog posts from WordPress to a custom Django application. It looks a bit intricate, but it did not take more than an evening of coding. Start from the obvious: WordPress exported XML The WordPress native export functionality gets you a custom XML file, mixing your post data, with a lot of information you do want necessarily to keep, because it is needed only by WordPress internals (for example, post ids).

  9. Strings and unicode in Python

    This post wil be about strings and encodings in Python, with an eye to Python 3 migration. Hopefully, you will find some useful rules of thumbs to to navigate these sometimes perplexing questions.'String' types What you commonly call a string can be two different things: Now this is extremely rough and even incorrect (unicode is just onestandard, there are non unicode encodings) , but you the aim is to get a working mental model.

  10. Django CSRF verification failed

    If you migrate to Django 1.2 you might encounter a CSRF Verification failed error when rendering a form. An interim solution is to enable django.middleware.csrf.CsrfResponseMiddleware: CsrfResponseMiddleware is there for legacy compatibility. If you want to use the features introduced in Django 1.2, CsrfViewMiddleware should take care of all CSRF needs at the middleware level. The new CSRF functionality relies on modifying individual views. Views in need of CSRF protection should provide a special variable in the template rendering context.

  11. Interview with the author of Nginx HTTP server, Clément Nedelcu

    As promised, here is an interview withClément Nedelcu, author of the first English book on the Nginx web server, namely Nginx HTTP Serverfrom Packt Publishing. Hello. Can you introduce yourself to our readers? Hi Ludovico and thanks for your review. My name is Clément Nedelcu and I am a French native currently residing in China. I have worked in the computer science industry for almost ten years now and I own a large network of popular websites.

  12. Book review: Nginx HTTP Server

    Packt Publishinghas provided me with a copy of their new book, Nginx HTTP Server(this URL contains a tracking code for Packt to monitor their marketing efforts) by Clément Nedelcu, kindly asking me to review it. They sent me a PDF version of the book, which is litte more than 305 pages in length. You might be aware that Nginx is a very fast and lightweight server developed by Igor Sisoyev, originally for the Russian portal site rambler.

  13. Django: display the current language in a template

    It is good practice to use the lang attribute to specify the language of an HTML document Of course, you could hard code the attribute by yourself in the template; but this information is stored by Django in settings.py (as LANGUAGE_CODE): so why not keep it DRY and retrieve it from there? Unfortunately, there is no default way to access information in settings.py from a template. One solution is to write a custom template tag.

  14. How good is Django, the Python web framework?

    Ok, as you know, you are never happy until you have written your own blogging software. So I went the easiest way and I did in Django. As you can see, we lost the comment functionality. I hope it will be back soon; but I need a way to protect this blog from those pesky spammers. Now, for a mini-review of how Django fits this site, and Django compared to a CMS like WordPress or Drupal.

  15. Django 1.2 and the new syndication API

    While mainaining backward compatibility, Django 1.2 has introduced a new Feed API which is more in tune with the rest of the framework. This post will  to explain how to migrate from the previous Django syndication API  to the new one.

    The old way

    In Django 1.1, an  RSS feed was something like this:

    from django.contrib.syndication.feeds import Feed
    from models import Entry
    
    class LatestEntries(Feed):
    

    You had to associate the feed to a URL with a dictionary which mapped the feed slug to the class. This made /updates.rss return our LatestEntries feed:

    The syntax was a bit too verbose, and the feed URL was split between the regular expression and the dictionary key.

  16. Introducing the Python defaultdict

    A defaultdict is a dictionary with a default value for keys, so that keys for which no value has been explicitly defined can be accessed without errors. Let’s see it in action. Frequencies Suppose you are given a list of words and you are asked to compute frequencies. You could do something like this: Unfortunately, Python throws a KeyErrorthe first time through, because you cannot increment the the values for the words, as they have never been initialized.

  17. Creating a QToolbar with QT Designer

    Adding the QToolbar to a QMainWindow In QT Designer 4.62, do not look in the widget list. Instead right-click on the main window and select Add toolbarfrom the context menu. To add buttons to the toolbar, you must create some QActions. Select the Action Editortab (if the tab is nowhere to be seen, go to the view menu and make sure Action Editor is checked), push the create new actionbutton and fill the form that appears.

  18. Python profiling with cProfile

    Compared to Perl's Devel::NYTProf, Python profilers are a bit rough around the edges. The recommended profiler as of 2.6 is part of the standard library and is called cProfile. It works only at the function (as opposed to statement) level and fancy graphical output is non existent. Here's a brief overview of what it offers. Profiling output For each function, cProfile makes the following data available: Two different datasets are headed percall.

  19. How to write books for the Web?

    What can you do with a book when it’s not on paper? Comments Well of course. Publishers should at least provide some mean of entering comments or reviews on the book site. Also people could publicly annotate the book at specific points, like the Django book(a book about a software development framework) Continuous updates We are not pushing the envelope enough in terms of continuous updates, addiction factor: take a cue from technical publishers:O’ Reillyhas live books, published drafts, book upgrades.

  20. SQL vs NoSQL

    MongoDB and CouchDB have been gaining traction because of performance and scalability. But are performance problems inherent to the relational model? Michael Stonebraker argues that traditional database systems performance problems occur in communicating with the applications and logging. Michael Stonebraker, who has worked on Ingres, is one of the fathers of contemporary database systems. In his post he mentions briefly another traditional argument of relational model advocates: SQL as a higher-level abstraction.