Canon EOS Rebel / 400D, libgphoto2 and Gentoo

I had some troubles yesterday importing images from my new Canon EOS Rebel XTi to my Gentoo - I installed UFRaw and gtKam and was trying to import RAW images into GIMP. For some reason gphoto2 wasn’t seeing my camera (although it was listed with lsusb) and so I couldn’t import photos from it using any application.

After several attempts (and very little information on Google), I gave up and went to sleep. Today I tried again and a solution came surprisingly fast: The problem was probably that I didn’t compile libgphoto with ptp2 support. What I did was:

- Add ‘CAMERA=”canon ptp2″‘ to /etc/make.conf
- Emerge libgphoto2, gphoto2 and hal again (I’m quite sure libgphoto2 was enough).

Now everything works and I’m off to play with some RAW images with GIMP.

Zend Conference POST-Mortum

Zend/PHP Conference 2007 is over - it was lots of fun and lots of work, and I enjoyed it even more than last year’s ZendCon. San Francisco was as beautiful as always, meeting colleagues from all over the world (some of whom I get to see only once a year) was fun, and of course, you get to learn from the smartest people of the PHP world, and also get drunk with them!
[more...]

Happy New Year, PHP Israel Users Group!

As some of you might know, the beginning of year 5768 of the Hebrew calendar is being celebrated in Israel these days - and for the new year, me and some friends decided to try and organize PHP-Israel - a local PHP users group in our land of milk and honey (or was itblood sweat and tears?).

So now we have php-israel.org (sorry folks, it’s all in Hebrew). It’s been around for less than 2 weeks and we already have ~40 or so subscribers to the mailing list - quite allot are Zenders but the majority are not, which is good. We also have some traffic - people are designing a logo and talking about a first meeting.

I’ve always thought there’s no PHP community in Israel - now I know there isn’t one because nobody tried to organize the quite numerous individual PHPers into a community. Hopefully, by next year, we will have a thriving local community of PHP users, spreading the word of the free web in Israel.

Shana Tova, PHP Israel!

Solve a CAPTCHA, help the world

I’ve just stumbled upon a great idea named “reCAPTCHA”. The idea is that you use their CAPTCHA challenges to protect your site from spammers and bots, or to hide people’s email addresses - but the cherry on top is that when people solve CAPTCHAs on your site, they also help digitize books by filling in words that OCR could not process.

According to the creators (from the site: “reCAPTCHA is a project of the School of Computer Science at Carnegie Mellon University “):

About 60 million CAPTCHAs are solved by humans around the world every day. In each case, roughly ten seconds of human time are being spent. Individually, that’s not a lot of time, but in aggregate these little puzzles consume more than 150,000 hours of work each day. What if we could make positive use of this human effort? reCAPTCHA does exactly that by channeling the effort spent solving CAPTCHAs online into “reading” books.

So they take the words OCR programs fail on (meaning: those are hard CAPTCHAs for bots to solve in the first place) and ask humans to solve them - and when they do, they use the words to fill in the OCR blanks. Now how cool is that? I’m definitely going to look deeper into this when I have a few free moments.

They even have API libraries in several languages, including PHP.

What I have always thought is now official

Ever tried looking up your name in Wikipedia? Check this out.
I knew it - and the title says it all.

Zend Framework 1.0 is out

Happy times and great success! 1.0 is finally out, and I’m sure it will (already has?) got quite allot of coverage in the PHP blogsphere - and even got into the main page of Digg - so I’m not going to write about the framework too much - however I do feel a personal retrospection is in place…

I joined the ZF community back in May 2006 (at least this is the earliest SVN commit I could find) - I made some complaints about the HTTP client, and Andi suggested I take charge of it. One thing led to another, and I ended up rewriting the whole Zend_Http classes. Things were not always done the “framework” way (there were no proposals or specs up until later in the development process for example), but I think the result is decent and useful.

There is already lots of talk about the next stages - we’ve been in a feature freeze for quite some time, and I have plans for several requested changes and new components: It seems that in the last couple of weeks the growing interest got people to report bugs and ask for interface changes - ironically at the stage when it was to late to make any changes. So there is already a list of proposed improvements to Zend_Http classes - I plan on doing some work on Zend_Http_Cookie and Zend_Http_CookieJar - and perhaps one day also improve Zend_Http_Client doing things like creating a Zend_Http_Request class that will be inter-operable with Zend_Controller_Request_Http. Also, there is the much needed support for CONNECT requests for HTTPS proxying - and more.

Additionally, I put up (and am still updating) a proposal for Zend_Service_PayPal - a PayPal web services component. Hopefully this proposal will be accepted soon, and the pieces of code I already have can be moved from the laboratory to the incubator, and from there to the main library.

So the future of Zend Framework begins today, and 1.0 is definitely not the end - in fact, I have a feeling this might just be the beginning of, well urm.. a beautiful friendship ;)

Finding Apache’s Memory Usage

I was doing some work optimizing the memory usage and performance of Apache and PHP. Along the way, I hacked this tiny CLI PHP script (which in turns uses awk, grep, ps, xargs and pmap) to find out the average private memory consumption of all Apache processes. Very useful when you want to see how much RAM your binaries eat before and after handling requests (they tend to grow, that is why MaxRequestsPerChild is so important…)

You can get the script here. It can be executed either by chmodding it executable (chmod a+x) and running it (if you have a PHP binary in $PATH) or by running `php ./memusage.php`. It might give more accurate results when executed as root, due to the nature of pmap and memory access restrictions.

You might also have to change the value of $apache_proc to match your Apache binary name (for example on Debian and Gentoo that might be ‘apache2′ instead of ‘httpd’).

It works by finding the PIDs of all child Apache processes, running them through `pmap -d` and averaging the results. I bet an experienced bash hacker could have done it all in one line with no PHP wrapper, but I just couldn’t find a way to convert the output of pmap into proper numbers (without the “K” suffix), so it was easier to do the math in PHP.

Needless to say, this is a *nix script, and was tested with Debian Linux. If you’re a Windows user, you should start looking for a $50 nagware that does the same, or even better, start migrating now ;)

SVG as your MVC View

Lately, I’ve been playing with the SVG format - a W3C backed XML format for Scalable Vector Graphics. Firefox can now render SVG natively, and this opens the door for lots of fun things you can do with it.

There are already very nice implementations of PHP classes that, for example, generate nice graphs using SVG - although I’ve never used it, the eZ Components Graph module is a very good example.

However, if you are looking to generate graphics dynamically from a pre-built template, you don’t really need to use any libraries or heavy OO and XML abstractions. Since SVG is just another type of XML, just like XHTML, using PHP to generate dynamic SVG is quite intuitive. Looking at this from an MVC perspective, you can think of SVG as yet another form of view for data - and it can be quite easily used as a “template” just like XHTML is used.
It is also quite easy to embed SVG into XHTML or vice-versa - but this means that you will need an SVG capable browser in order to render the page (did I already mention Firefox is one?)

I am still playing around with the format and with the whole concept - but in the mean time, here is a (non-scalable png) screenshot of an SVG graph I generated using simple PHP code:

SVG Graph

You can see how this graph is embedded within XHTML and generated here - it also shows the entire source code. A few notes though:

  1. I have no idea how other browsers render this. It works with Firefox - I’m quite sure IE (even 7.0) does not render SVG without special plugins
  2. Pay attention to the header() call - it’s important!
  3. The use of Zend Framework is there only for fetching the data from digg - the real stuff doesn’t rely on Zend Framework

If I have enough time (and I’m able to get myself to focus ;) ) I’ll study this some more and maybe build some nice tutorial.

Server Cooling

A small fact I’ve learned today about server farm cooling: In Finland, they don’t cool server rooms.

They just ventilate, or open a window.

Upgrade to 2.6.19 kernel issues

I have been quite busy lately, trying to find a new apartment in Tel Aviv (not an easy task), and under allot of work. I’ve decided to take advantage of the rainy weekend to do some maintainence on my laptop, including a kernel upgrade from 2.6.18 to 2.6.19 (Gentoo ck-sources).

It seems that 2.6.19 introduced some major changes in ATA/SATA drives. For some reason, my SATA drive is no longer /dev/sda as it always was, but is now /dev/hda (which kind of makes sense, as it is not a SCSI device…). This in turn caused quite a headache - it has been long since I had to work hard for a kernel upgrade. [more...]