WPtouch Pro! is a WordPress plugin for self-hosted WordPress websites that shows a well-designed mobile theme version of your site when visitors are using popular touch mobile devices like the iPhone/iPod touch, Google Android phones, Palm Pre/Pixi, Samsung bada and Blackberry Storm & Torch devices.
Read More

We have come a long way in web development – from static sites to distributed applications in the cloud; helped by a plethora of languages and frameworks. Many technologies made a surprising return – like the Phoenix rising from the ashes, JavaScript made a resurrection and with it the rise of libraries like jQuery and others; CSS helped us create stunningly attractive sites and entice the audience. But after all these years and the amazing technologies at our disposal, the websites we create are still fundamentally dumb in nature.
Read More

Merge multiple PDFs using Ghostscript

Posted in: linux |  

1 Aug 2011

Merging multiple PDF is not a common task, but it is good to know how to do it once the requirement arises. Specially if you want to merge documents from within a language like PHP. Although there are a few PHP classes that do the job, many throw out errors due to incompatibility between different versions of PDF and the compression used thereof. The last good (and free) solution I found was that of using Ghostscript to merge the PDF’s, and calling the command from PHP.

A simple Ghostscipt command to merge two PDFs in a single file is shown below.

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf

Search-engines have reached a impasse with respect to understanding of HTML data. Although most sites, especially databases centric sites use structured data in the backend, once the data is rendered as HTML the data looses all its structure and makes it difficult for search engines to understand them correctly. Until now most search engines have relied on extracting keyword text from the web pages and ranking the pages accordingly, taking the context around the keyword into consideration. This obviously has its limitations and it can only take you so far.
Read More

The following is a very short code to read the version number of a PDF document using PHP. I needed this recently during a PDF processing app developed in PHP. As Adobe uses different compression methods in various versions, it becomes necessary to be able to identify the version of the PDF under work.
Read More

Tail functionality in PHP

Posted in: php,tip |   ( 6 ) Comments

18 Jul 2011

Frequently one needs to get the last few lines of some log files, whether php error logs or Apache logs. Most of these file sizes run into megabytes, which makes it difficult and time consuming to remotely open them using ftp. If you have shell access then you can easily use the *nix ‘tail’ command to return the last ‘n’ lines; or one can use the following if shell access is not enabled on your hosting.

function Tail($filename) {
  return system('tail -n 20 '.$filename);
}

Read More

JavaScript Photo galleries are dime-a-dozen, with a large number of variations in size and features. But this particular one developed using Mootools is a breath of fresh air. Most galleries are spatially bounded, i.e. they have a limit how how much you can scroll in any direction.
Read More

During a recent project I needed a database of IATA airport codes. Airports around the world are universally known by a unique three-letter code: the “International Air Transport Association (IATA) Location Identifier”. It is much easier for pilots, travel agents, frequent flyers, baggage handlers and anyone having anything to do with airlines to say and write LGA then the full “New York, NY – La Guardia Airport“.
Read More

In a previous post we saw how to detect human faces in images using JavaScript. In the current post we will look into a PHP port of a JavaScript face detection algorithm without using openCV. Since the code is completed written in PHP it cannot attain the raw speed that C,C++ provides, but for many trivial application a PHP version can do.
Read More

Retrieving email Gravatar images

Posted in: php |  

30 Jun 2011

Below is a quick hack to retrieve and save Gravatars. Gravatar images come in various formats, but we don’t detect them here, just save the retreived image in ‘jpg’ format.
Read More