Thursday, November 29, 2007

How To Detect Mobile Devices on Your Site

This is not an easy task if you don't know what kind of headers were sent from various mobile browsers and how to detect them. But this php script on Andy Moore's sites shows you how you can detect them effectively. You can easily modify the script to work on any other language you prefer.

Sunday, November 18, 2007

Powerful Linux Find Command

If you want to find files in a certain directory modified sometime ago, you could use these commands to find out easily:

* Example: find everything in current directory modified in the last 24 hours:
  • find . -mtime 0

* Example: find everything in current directory modified in the last 7 days:
  • find . -mtime -7

* Example: find everything in current directory that have NOT been modified in the last year:
  • find . -mtime -365

* Example: find everything in current directory that had been modified more recently than "abc.txt":
  • find . -newer abc.txt

Monday, August 06, 2007

How Vbulletin Report Post Function Works

Ever wonder what Vbulletin Report Post function does? The message does not go anywhere to the AdminCP or ModCP. Instead it just sends out email to moderators of the respective forum. If no moderator is assigned to the forum, the email is sent to the Administrator of the forum. However, you can change the default behaviour from AdminCP->Vbulletin Options->User Infractions & Post Reporting Options->Post Reporting Email. There are three options to choose, No Email, Post to Moderator, Post to Moderators (default), Super Moderators and Administrators.

Monday, January 29, 2007

Making Your Spring Service Layer Classes Application Context Aware

Spring framework has a nice feature to make your service layer classes applciation context aware. Basically, wiht ApplicationContext you can get messages stored in properties file. For JSP pages this can be easily done with tag libraries. But from the service layer classes, it is quite difficult to get those MessageResourceBundel class and other configuration settings. By implementing ApplicationContextAware from your service layer class, you get a reference to the ApplicationContext object and read in whatever properties you want to read. Below is a code snippet:

public class xxxxController extends FormAction implements ApplicationContextAware{
..................


public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.appContext=applicationContext;
}
}

Once this code has be inserted, you are ready to get the messages in the properties file like this:

String message = appContext.getMessage("your desired message name", new Object[]{param1,param2}, Locale.getDefault());

where param1 and param2 are of any Object type that you want to inject to the message which has the format like this:

Hellow {0}, today is {1}......

Tuesday, January 16, 2007

Web 2.0 logo creator by Alex P (Alternate link)

Thanks to Alex for coming up with this kool piece of tool. It has attracted so many visitors that the main site is not working anymore. Here is the alternate link to generate the images http://h-master.net/web2.0/index.php.

Here's what I have created and the code I used to generate this image.
[c=FF0000]D[/c][c=00C400]O[/c][c=0000FF]R[/c][c=FF0000]I[/c][c=0000AA]S[/c]

Generated Image