Writing an efficient typeahead data structure

I’ve been wanting to implement a typeahead lookup for universities and thought it would be an interesting weekend project to write an efficient typeahead lookup dictionary structure. It turns out that quite a lot of thought needs to be put into this in order for it to work efficiently. Initial Considerations I looked at quite [...]

Deny requests by IP address on an Apache server

It’s very unlikely that someone will legitimately access your web server by IP address in his or her web browser, and it’s almost guaranteed to be a bot of some sort. To prevent access to your server by IP address, it’s necessary to examine the ‘host’ header in the HTTP request (HTTP_HOST in Apache) and [...]

A simple cron job to perform a recurring MySQL database backup

I’ve written a simple script that performs a MySQL database dump and can be added as a cron job to run at regular intervals. This script will dump the entire database to a file and gzip it, while also creating a log of its activities. Before starting, identify which user the script should run as. I [...]

Live template in IntelliJ IDEA to generate serialVersionUID

Live templates in IntelliJ are cool. They reduce the number of keystrokes you need for repetitive code. One problem is adding the serialVersionUID value to a serializable class. If you have the serialization inspections enabled (Project Settings > Inspections > Serialization Issues > Serializable class without ‘serialVersionUID’), then IntelliJ will warn you and you can [...]

Override Wicket’s redirect to use “301 Moved Permanently” instead of “302 Found”

HTTP status codes 301 Moved Permanently and 302 Found are used to redirect a user’s web browser to a different location. A user will never notice the difference if your server sends a 301 or 302, but sending a 302 can have negative SEO implications, such as PageRank not transferring correctly to the target page. [...]

Regex to identify an IE 6 user agent without blocking MSIE 8 or 9 users

I recently had a need to block all IE 6 users from a web site. After doing some log analysis, it looked like nearly every IE 6 user agent was some sort of bot or undesirable crawler. The browsing patterns made it very obvious that the requests were not coming from a human, and sometimes [...]

Check if a user already exists in a sign up form with a Wicket validator

A common use case during user sign up is to check if the user already exists, either by email address or by user name. Wicket makes this simple. The following example demonstrates how to verify that an email address isn’t already in use. It would be easy to write this to do a user name [...]

Adding a rel=canonical link in Wicket for duplicate content

Google recently introduced a new <link rel=”canonical”> tag to help the search engine identify duplicate content across domains or pages. I’m working on a development project that contains many subdomains under a single domain to present content specific to various geographical areas. Some of the administrative pages under each subdomain contain the same content (such [...]

Apple Store’s usability is great, but…

I’ve been eyeing a new MacBook Pro for a while and decided to pull the trigger during Apple’s Black Friday promotion. Since I wanted some custom upgrades, I bought it on Apple’s online store instead of at an Apple Store. Apple’s done a great job with their site’s usability, but I found a few things [...]

A case for declaring your variables as final in Java

I wrote a few months ago about Yoda conditions and using the final keyword. I recently came across a bug that would never have occurred if a final keyword was used. Consider the following code. I’ve simplified it to the point that a static map structure could be used, but that was not the case [...]