Learning one new language every year

Here’s an update of the current status of my “one language per year” lifelong initiative:

  1. 1992: QBasic
  2. 1993: Turbo Pascal
  3. 1994: C
  4. 1995: Delphi
  5. 1996: Java
  6. 1997: JavaScript
  7. 1998: VBScript
  8. 1999: Transact-SQL
  9. 2000: C# + Prolog
  10. 2001: C++
  11. 2002: PHP
  12. 2003: Objective-C
  13. 2004: Visual Basic.NET
  14. 2005: Ruby
  15. 2006: LINQ
  16. 2007: Erlang
  17. 2008: Python
  18. 2009: Go
  19. 2010: Lisp
  20. 2011: Haskell

The trend has roughly been an evolution from procedural during the 90′s, to object-oriented ones at the beginning of the 2000′s, and finally to functional languages right now.

And thus I realize, I’ve been programming for 20 years this year, 15 of which for a living.

Del.icio.us to WordPress

I’ve just uploaded a new project on Github called delicious_wp: it’s a small Ruby script that simply fetches the items stored in del.icio.us the previous week and creates a blog post with them. You can set up a small cron job to execute this script every week, which is what I’ve done for this blog :) I know del.icio.us has a similar feature integrated, but it executes daily, instead of weekly, which is what I wanted.

To use it, just clone the repository, copy the config.yaml.sample file as config.yaml and edit its values inside. Run the script and voilà! A new blog post entry with your del.icio.us bookmarks.

The script can also be helpful to those wondering how to use the XML-RPC interface of WordPress from a Ruby script, or how to use the Net::HTTP library to consume a REST API.

[source:ruby] def get_delicious_bookmarks # Connect to delicious and get updates http = Net::HTTP.new(DELICIOUS_SERVER, DELICIOUS_PORT) http.use_ssl = true req = Net::HTTP::Get.new(DELICIOUS_DATES_PATH) req.add_field(“User-Agent”, DELICIOUS_USER_AGENT) req.basic_auth username, password response = http.request(req) results = response.body [/source]

[source:ruby] def post_to_wordpress(title, text) entry = { :title => title, :description => text } # Connect to WordPress using the XML-RPC interface blog = XMLRPC::Client.new(server, path, port) blog.call(“metaWeblog.newPost”, blogid, username, password, entry, true) [/source]

Enjoy! As usual, the code is released with a BSD license.

WordPress 2.8 and the get_link() error in line 647 of dashboard.php

Wow, that’s a long title, but it should drive people with this problem right here. If you have upgraded your WordPress installation to 2.8, you might have encountered a nasty error in your Dashboard, which says something about a

Fatal error: Call to a member function on a non-object in /home/user/www/wp-admin/includes/dashboard.php on line 647

This has been reported in the WordPress site but no fix has been provided. I found elsewhere a possible fix, but in my case, the new URL would not be saved at all, and the problem would persist.

I fixed it using a good old method, enabled by Open Source™: editing the code directly; I’m posting it here for those of you who would like to do it, until 2.8.1 is released:

[source:php:firstline(646)] $author = $item->get_author(); if ($author == NULL) { $site_link = “”; $publisher = “Someone”; } else { $site_link = esc_url(strip_tags($author->get_link())); if ( !$publisher = esc_html(strip_tags($author->get_name()))) $publisher = __(‘Somebody’); if ($site_link) $publisher = “$publisher“; else $publisher = “$publisher“; } [/source]

OpenGL ES 2.0 on iPhone OS 3.0

Now that the NDA on the iPhone OS 3.0 SDK has been lifted (which happened much faster than what I thought it would take!) here’s my first contribution to the world of iPhone OS 3.0 open source code: sample code about how to use OpenGL ES 2.0 on the iPhone 3GS, something I announced in Twitter last week.

As you might know by now, one of the biggest enhancements (and yet, one of the most obscure) of the newly released iPhone 3GS is the new GPU chipset, which allows developers to create applications using Open GL ES 2.0 (together with Open GL 1.1, which was already available in the first two iterations of the iPhone). This is a major advance, invisible to the end user, which, coupled with the unprecedented performance boost of the iPhone 3GS, opens up the possibility to developers to create applications with new textures and effects, yet unforeseen on this platform.

Given that Xcode does not (yet) bring an Xcode template to play with, and that the OpenGL ES 2.0 Programming Guide book, by Aaftab Munshi, Dan Ginsburg and Dave Shreiner does not (obviously) bring iPhone examples, I have created a project in Github where I will be publishing the code samples in the book, as I progress in the lecture, ordered by chapter, ready to compile and play with.

Enjoy! I’m happy not having to use the word “[REDACTED]“ any more now (there’s the other OS, the bigger cat, but, oh well…)

Update, 2009-06-24: I just found this blog post by the folks of Black Pixel (Daniel Pasco‘s company) with benchmarks about OpenGL ES on the iPhone 3GS… and the first line says it all:

Holy crap, this thing is fast

Update, 2009-06-24: Jeff LaMarche just announced that the authors of the book have published iPhone – compatible code in the book website! That effectively renders this project useless :))

Best books of 2008

You might remember my beloved mantras: learning a new programming language and reading at least 6 relevant books every year. Following the 2007 edition, here’s the list of the 8 books I have enjoyed most in 2008, ordered by a purely subjective and absolutely irrational decreasing preference. I strongly recommend all of them!

Winner: Geekonomics: The Real Cost of Insecure Software by David Rice

Runner-up: The No Asshole Rule: Building a Civilized Workplace and Surviving One That Isn’t by Robert I. Sutton, PhD

And 6 more:

Continue reading

Challenges for Software Engineers

Software Engineering is the youngest of all the professions, being born around 50 years ago, but since then it has been continually improved. Practicers have fiercely debated upon it through the years, given the extremely fast pace of the innovations in the field, and the extremely difficult and inherently dynamic nature of software. Many trends have appeared and vanished, and many others will come.

In this article I will provide a short overview of two kinds of challenges that I consider that software engineers will have to confront in the next 20 years: the human and the technical. Continue reading

ImageMagick

ImageMagick is a cool toolkit; not only it’s a complete set of command-line applications, ported to Windows, Mac and Linux, supporting hundreds of different image formats, it’s also a C++ library that you can use in your own applications!

On Mac OS X, I installed it via MacPorts using the all-time classic:

sudo port install ImageMagick

Then I created a C++ command-line application with Xcode, set the header and library paths in the target properties (/opt/local/include/ImageMagick and /opt/local/lib in this case) and I was ready to code. The API documentation and the tutorial give some hints, and using those examples I’ve cooked a quick image transformation utility to play with:

[source:c]

include

using Magick::Image; using Magick::Geometry; using Magick::Blob;

int main (int argc, char * const argv[]) { Blob blob;

Image png;
png.read("pic.png");
png.write(&blob);
Image jpg(blob);
jpg.magick("jpg");
jpg.zoom(Geometry(100, 200));
jpg.write("newpic.jpg");
Image tiff(blob);
tiff.magick("tiff");
tiff.zoom(Geometry(3000, 84000));
tiff.write("newpic.tiff");
Image gif(blob);
png.magick("pdf");
png.write("newpic.pdf");
return 0;

} [/source]

Interesting stuff indeed! The API provides a complete set of “Photoshop-like” operations on images, which I plan to study further in the near future.

Symfony con MAMP

estuve jugando un rato con symfony y MAMP, y esta bastante bueno, aunque hay un par de cosas que no me gustaron. aqui van unos comentarios que te podran ser utiles.

me puse a leer las instrucciones de instalacion, y despues encontre el tutorial, de donde saco gran parte de lo que escribire en este articulo.

ahi dice que hay un archivo tgz que podes bajar de aca. se llama “sandbox” (caja de arena) y tiene todo listo y esta especialmente destinado para principiantes.

lo baje y lo descomprimi (haciendo doble click) en el web root – yo lo tengo seteado en ~/Sites, mira esta pantalla de configuracion de MAMP:

entonces puse la carpeta sf_sandbox en ~/Sites/sf_sandbox.

como tengo el MAMP andando abris un browser y te vas a http://localhost/sf_sandbox/web/index.php/

primero no me anduvo porque tenia MAMP con la opcion “PHP 4″, y la cambie a “PHP 5″ y anduvo:

Continue reading

wp-super-cache problem? Easy fix

I’ve just installed the excellent wp-super-cache plugin to accelerate things a bit in this blog; today somebody sent one of my pages to reddit and I’ve had more users than usual! – by the way, thanks for coming! :)

Update: I admit, it also has a bit to do with the reading of today’s entry in Coding Horror ;) But I love WordPress nonetheless. I prefer it over MovableType (which I used during one year and a half).

The only glitch was: at first, it didn’t work. I think you know the feeling.

The plugin was enabled, everything was activated, yet no files were cached: exactly this same problem. And I found a quick fix to it, hence this post: fire your FTP client of choice and go to /wp-content/cache. If you don’t see a “supercache” folder in there, just create it. Magically, if you have some traffic on your blog and you dig in that folder a couple of seconds later you’ll see already lots of files! No need to modify .htaccess whatsoever.

If you want to populate it, log out of the WordPress admin and start clicking on your blog. This plugin only creates cached files for anonymous visitors! I also turned on the compression so you should start having faster response times.

It was the only thing to do manually to get it working. Hope this helps! Any comments, as usual, more than welcome.

Installing PostgreSQL 8.3 on Leopard

This is the documented path to my discovery of PostgreSQL 8.3, which I’ve never used before. Now that MySQL‘s community is getting hammered to death by Sun, and thanks to all the good things I’ve heard about it over the years (including enhanced performance on multicore systems and greater scalability), I really wanted to install it and play with it.

Frankly, it’s not easy. At all (actually this is why I think MySQL is so popular, because of the ease of installation!) So hang tight and read on. Continue reading