Tuesday, June 14, 2011

me and my monkey...

no monkey. just "me and my code" concept, because of course there is a sense of (intellectual) property over the code a programmer writes. for those who even heard (not necessarely to read) of Hackers and Painter, by Paul Graham this post might sound very funny. of course, programming is a craft, and programmers are crafters, but still.


I am somehow intrigued by the voracity of marketing over the quality. I admit it is a mentality of a whole society. If you are born in a society where the individual rights are not strengthened by the higher state hierarchies, where the law of intellectual copyright is imported from foreign economies and societies without any effort to adapt it to "cruel reality", it is funny and perceived as a huge arrogance the simple fact I am about to describe in my next paragraph.

I am looking through a project which seems to be written by a single person (over 1500 files of PHP + HTML + CSS + JS code). I had different contradictory feelings: first I thought I am going to spend a whole day to make it work on localhost. Well...besides the 3 different configuration files with functions with same name and the comment of lines which made redirects to exactly the same link but with https instead of http - of course, no check if the request already comes from a secure url - nothing "spooky" yet. Then I find a class file (yeah...a class...who would have thought of that?). 'til line 137 we have the definition of private variables. 'til line 250 or so we have the constructor which initialize each variable with values (like '' or 0). then, 'til line 1200+ we have getters and setters for each variable:). I scroll down the file with over 3500 lines. Guess what? NO COMMENTS! none! zip! zilch! nada! until...the last lines which contain a copyright note, the author's name (for god's sake, at least don't put your real name there!!!) and of course the magic lines:
// This code may not be copied, sold, or used as a derivative work
// without the express written permission XXX
and here I am, wondering...who on earth would want to copy your code? I swear and cross my heart I will never be able to sell that code (I think the author of it actually had that problem). I would never say making that code to work that I am using it as a derived work. And no one should say that too. I am fixing it, improving it, make it run properly, use common sense and basic logic on a bumble-mumble product which, funny or not, is the INTELLECTUAL PROPERTY of another human being. Now I am the arrogant one, but I am forced to it, and I hate it. And believe me or not, but this kind of people have all the chances to rule the world.

Isn't it sad?

P.S.

Thursday, June 9, 2011

Timthumb and filenames with spaces issue

It is known that some of older timthumb.php versions have an issue with displaying pictures with spaces in their file names.
Altering the timthumb.php file:
1. just because I am paranoid, before the call of clean_source($src); (around line 40) function I added
$src = urldecode($src);
On front side I generate the pictures sources from jQuery + jquery.urldecoder.min.js and use $.url.encode(picture_source)
2. comment line (about 672) containing the code:
$src = str_replace (' ', '%20', $src);

Or best thing to do: update the timthumb.php file to last version!