/* PHP & MySQL Journal */
Posted in: browser, general, software | ( 2 ) Comments
25 Apr 2010
Interface design is hard. Which is why most programmers turn a blind eye to it. During collaborative development I frequently encounter fellow programmers remark something to the following effect: ‘…do not worry, the users are not idiots, they will understand for what these buttons have been provided, no need to provide tool-tips or any help, lets get these code working and show it to the client.’
Interface design or rather usability design is usually left as an after thought; a colorful facade that you stick on to your backend code.
The following two videos provide a stark reminder, that for most of the time these are the people we develop software for.
Posted in: api, data, libraries | ( 2 ) Comments
15 Apr 2010Geographical information integration is rapidly becoming an integral part of many websites. People use geographic data for a wide variety of applications. From location based content targeting, censoring information by geographic areas to analyzing website traffic by region. It is surprising how much free geographic information is available on the web. GeoNames is one such service.
Posted in: html5, wordpress | ( 5 ) Comments
6 Apr 2010Only if partially, but HTML 5 is slowly getting increased support from various browsers. Some of the HTML 5 features like ‘canvas’ and ‘video’ are supported by browsers like Firefox, Safari, Google Chrome and Opera. In this post we will look into how to add the HTML 5 ‘canvas’ tag to your wordpress posts.
The Canvas element consists of a drawable region defined in HTML on which you can dynamically draw graphics and animations using Javascript. The canvas API provides a nice set of drawing functions to play with.
Posted in: general, tip | ( 3 ) Comments
25 Mar 2010Blank lines are an eye sore for source files. During the last few weeks I’ve been shuttling php and html files from various host servers and my PC. During the whole ordeal the source files kept adding a huge number of blank lines. At one point an ‘if’ construct in one of my PHP code was about 60 lines away from the next starting brace. This was all caused by the non standard newline character, also known as a line break or end-of-line (EOL) character. As we all know, it is a special character or sequence of characters signifying the end of a line of text. Unfortunately the actual codes representing the newline differ across operating systems, which creates problems such as the above when exchanging data between systems. If you think you don’t use *nix systems and are therefore free from these problems then you are wrong. Even though you may be using Windows, most host servers are Linux based, and so transferring files back and forth from these servers can create these kind of problems.
Posted in: google, libraries, php | ( 63 ) Comments
2 Mar 2010Google translation is an interesting service. Not only can you do language translation, you can also detect the language of a particular text. I recently needed to create a Wordpress plugin to translate post titles from one language to another. As the translation API is only available for Java and Javascript, I decided to create a quick one for PHP. In this post we will see how to translate text from one language to another in a simple and quick way using the created class.
Posted in: mysql, wordpress | ( 4 ) Comments
12 Feb 2010
Building and running a Wordpress site is a simple matter. Wordpress is a considerably fast CMS system, until you start to add more and more plugins and one day you notice that Worpdress has started to slow down. It may be the case that SQL queries within some plugins are not optimized and are taking an increased amount of time executing them, this can considerably slow down your site. The first thing you can do to rectify the situation is to find out where exactly the bottleneck resides by analyzing the time each SQL query takes to executes. Some inquisitive people among you may also be interested in knowing in what sequence the Wordpress SQL queries themselves are being run. Not that all bottlenecks occur due to unoptimized SQL, most are due to poor coding practices. Whatever the reason; the following post will show you how to look inside the SQL query execution of Wordpress.
Posted in: google, php | ( 14 ) Comments
1 Feb 2010Google Analytics has become a important part of any web sites traffic analysis strategy. And with the release of the Analytics API people have been able to create custom reports and mashups for their organizations. Although no standard library is available from Google for PHP, some small and easy interfaces are available out there. In this post we will see how to access Google Analytics data using PHP using the GAPI library.
Posted in: php | ( 3 ) Comments
30 Jan 2010PHP programmers are frequently into using the various is_x group of functions: is_int, is_null etc. All of this functions take a single parameter which leads you to believe that other similar constructs take only a single parameter. Like the isset and unset constructs, which by the way take multiple parameters as shown below, which might help you save some keystrokes.
Posted in: testing | ( 9 ) Comments
10 Jan 2010In the previous Selenium posts we saw how to use the selenium IDE for testing web pages. In this post we will see how to extend the Selenium IDE by adding our own custom commands.
Selenium IDE offers many useful commands (often called Selenese) for testing purposes. You use this sequence of commands to create various tests. But many times these commands are not sufficient and you need to add your own custom commands. For example a reader recently requested on how to input unique email ids for testing. Of course you can easily do this using the Selenium RC server and a language like PHP or Java. But we want to accomplish this in the IDE itself.
Posted in: testing | ( 3 ) Comments
21 Dec 2009PHPUnit has become the de-facto standard for unit testing PHP code. Now in version 3.4, it has added many new and interesting features to its repertoire.
PHPUnit 3.4 now supports dependencies between different test methods. It allows you to execute a particular test ONLY IF the test that it depends on executes successfully. Take the following example (Listing 1.) where we test a linked-list class I developed earlier.