The Developer Day | Staying Curious

Archive for September 2008



Web Applications on Mobile Phones using PHP

I’m a subscriber to a PHP magazine php|architect. I still haven’t finished reading the july edition. In the past I didn’t have to do much with web applications and mobile phones. Recently though we had to make a certain part of a bigger application we made to be available on blackberry. The problem of course we faced is of course how to identify if the current agent is a mobile phone. And that’s how we found WURFL.WURFL aka Wireless Universal Resource File is a device description repository or to make it simple it’s a big library of various mobile phones abilities and attributes mapped to user agents.

What does this have to do with php|architect? Well in the 2008 july edition of php|architect there is a really lovely article about web application tools for mobile phones. I found there are two more PHP tools that a mobile web applications developer should know of. It’s Tera-WURFL and HAWHAW. And again to make it simple Tera-WURFL is a mysql database for WURFL to make WURFL super fast and HAWHAW is a object oriented toolkit to create mobile web applications. Basicly with HAWHAW you can construct pages using objects and then HAWHAW renders them to apropriate formats such as WML, XHTML MP, XHTML using the data it gets from Tera-WURFL. According to the php architect article Wikipedia is using HAWHAW.

I don’t have to do much with mobile web applications I think it’s great that these kind of tools are available because I know it is easy to develop these kinds of applications if I or others have to.

, , , Hide



In my previous blog post I wrote that me and my friend probably developed a first working google page rank check php implementation on linux. Seems I was wrong. Jan Bogutzki has an implementation on his website that also works on linux. He sent me his version of implementation and I must admit it looks cleaner and more simple than ours. You can download the copy he sent me if you are after a better approach.

, , , Hide



If you found this blog post on while searching for a php google page rank class implementation that works on non windows machines then it is your lucky day! You found it! Congratulations!

To my knowledge this is the first available php google page rank retrieval implementation that works on any platform. We have spent hours searching for such a thing online but we couldn’t find it. There are some php google pagerank tools online, they all work, but they are all limited to windows machines.

Why is so you might ask? Well originally the google pagerank retrieval algorigthm is not public. But google made a browser plugin that was able to calculate the google pagerank for any website you visit. So some freaky geeks dissasembled that plugin and got their hands on the google page rank calculation implementation.  Then this implementation was ported to various languages such as Javascript, PHP. The google page rank implementation is sort of protected by calculating a “unique” hash of the given URL. And here the MAGIC begins.

To calculate this hash the algorithm overflows 32bit integers on XOR operations. Aaaand.. 32bit XOR overflows work quite differently on windows and linux in PHP! If you overflow a 32bit integer on windows it just truncates the result to 32 left most bits and returns a new integer. SMART! And on linux XOR overflow just returns the MAX INTEGER value. What did we do? Oh.. We created a simple class to simulate windows 32bit XOR operations overflow using the PHP gmp extension. Tadam! We have also cleaned up the code, documented and made it look shiny ;)

You can download  and use it at your own will. I hope this will help you. If it did just leave a comment and say thanks because we are such nice guys to help you out ;)

To use the class try:

Happy Programmers Day!

p.s  Google™ search engine and PageRank™ algorithm are the trademarks of Google Inc.

Update: PageRank class relies on the GMP extension which is not always enabled by default. On Linux Ubuntu it comes as a separate package php5-gmp.

, , , Hide



PHP Zend Certification Exam

Previously I wrote that I would like to take the Zend Certification Exam and I thought I could review every chapter of the Zend Certification Exam study guide. Well I think i have lost my inspiration somwhere along the way. Though I recently found a blog that already did what I wanted to do. Check it out and see if it helps. I also found out about Paul Reinheimer’s Zend Certification Exam course which is available as a free PDF on the internet and could be really useful to prepare.

, , , Hide



Linux like terminal on Windows!

Have you ever wanted to make your CMD window fullscreen? You did? And it didn’t work? Too bad. Have you ever wanted to search something in your files using grep, awk, less, sort? Have you ever tried to mass rename your files ? You did? And it didn’t work? Too bad.Be worried no more! First you need Cygwin. Cygwin is a Linux-like environment for Windows. It also provides you a lot of tools which provide linux look and feel. Install cygwin while changing none of the default settings. Now you can do something like this:

Cygwin Terminal 

Notice that this is a simple CMD like window but it now has some nice colors and new shiny tools.Now in order to make it even more cool you need a tool named PuTTYcyg. PuTTYcyg is a patched version of PuTTY that, in addition to telnet, rlogin, ssh, and serial connections, can also be used as a local Cygwin terminal instead of the Windows console. Download the package and unzip it somwhere. I put it in C:\Program Files\puttycyg. Now double click on a file named putty.exe. Now fill everything as in the image bellow and press save.

 cygwin putty configuration 

Now make a shortcut of this putty.exe on your Desktop. And change it’s properties like this:

cygwin putty terminal shortcut  

Click apply and you are ready to go myfriend! Double click on the shortcut and you should be able to do thins like this including full screen resize yay!

putty cygwin terminal 

Now .. Begone CMD!

, , , Hide

I was really happy to see that most of the Drupalcon 2008 talks videos were published. There are a few general talks that I would like to highlight.

One talk that really impressed me was “Rasmus Lerdorf keynote - Simple is Hard“. I found it to bee very interesting, exciting, funny and shocking. It opened my eyes to some extent not to overdo with abstractions and mega layers and take a look at simple things like transactions per second. The inclued pecl extension just blew my mind. Sadly there isn’t a DLL compiled for windows. But I’m definitely trying out this extension on our applications to see what kind of a mess we have.

There were also a few by Rasmus about PHP security at the end of the presentation that were really interesting. Few other talks worth mentioning: “Indexes and denormalization: keys to scaling sites with massive content” a nice introduction to indexes and how they work. And most importantly how you can’t have indexes on two tables using open source relational databases and how denormalization helps.

High availability solutions for MySQL: An Overview and practical demo” this one speaks for itself. If you are interested in replication, clusters and that alike this talk is for you.

, , , , , Hide

Find it!

Theme Design by