Most modern languages have a concept of packages, wherein related classes are stored together. PHP sadly doesn’t have a similar concept. For example in Java we can use the following line to imports all classes from the java.awt.event package.

import java.awt.event.*;

One of the most time consuming steps in developing a database based application is test data generation. Imagine you have created a shopping cart application for your client, containing dozens of tables and hundreds of fields. Everything is ready for testing, but the problem is your database is empty. You at least require a modicum of test data in the database to proceed with the testing. You can choose to manually enter a small set of random data into the database, but you lose a couple of precious days in the process. What you require is a data generator that automatically generates test data for your database.

Programming challenges

Posted in: puzzles |   ( 6 ) Comments

28 Oct 2009

Programming is about solving problems. To be precise, solving problems using a computing device. I love solving puzzles as do most programmers. Solving a challenging puzzle or a programming problem gives one a wonderful sense of satisfaction. Starting with this post I’ll be presenting a programming problem every week that will help readers take some time out from their routine work and have some additional fun working on challenging problems. Below is a small problem to kickstart the series:

Microsoft Fiddler is a HTTP debugging proxy that lets you log all HTTP traffic between your computer and the internet. Fiddler lets you to inspect all HTTP traffic, set breakpoints, and “fiddle” with incoming or outgoing HTTP data. To run Fiddler you require a Windows machine with .NET 1.1 framework installed.

nWire is a plugin for Eclipse that helps you understand the various components and their relationships in your application. Due to various complex PHP applications being developed – like Magento, Joomla and a wide variety of frameworks, developers finds it hard to understand the underlying architecture and relationships between various components within the application.

E-mails are a pervasive element of most web applications. But many times testing and debugging emails can become a hassle when many of them are involved. Most of the time you just want to be sure that the email part of your application is working fine, without flooding your mail account with test mails.

Every time you use your browser to access a website a User-Agent header is sent to the respective server.
Detecting user agents on the server can be useful for many reasons.

1. Browsers Quirks – Despite the standardization in browsers, there will remain some quirks in various browsers that you will need to iron out on a regular basis.
2. Personalize Content – It may be required to deliver different type of content depending on the browser type (although it is usually not recommended); whether mobile or otherwise.
3. Illegal Access – Prevent bandwidth hogging bots and poorly programmed clients from downloading your content.

Hello readers! The blog now has been updated with a new color scheme. The new and the previous one are shown below for comparision. Not that everyone will like it as each has his own favorite color palette. Basically I wanted to give the blog something of a red or maroon finish, but after tinkering a while I decided to settle around earth tones.

The following small code generates check digit for UPC-A codes. You can use it for example to generate random UPC-A codes.

Check digit calculation

The check digit is calculated as follows:
1. Add the digits in the odd-numbered positions together and multiply by three.
2. Add the digits in the even-numbered positions to the above result.
3. Find the result modulo 10 (i.e. the remainder when the result is divided by 10).
4. If the result is not zero, subtract the result from ten.

Beautifying XML documents

Posted in: data, pear, tools |   Add comment

10 Sep 2009

I frequently write php code to access various web services and the most common response data I encounter is in xml, which most of the time is not formatted. I use xmlPad to format and analyze xml documents, but many times I need to format xml documents on the production server wherein xmlPad is of no use. What one needs is a library that would allow you to beautify your untidy xml documents within your php code. XML_Beautifier provides that solution.

RECENT COMMENTS

ON TWITTER