Save drafts of form textarea inputs in Apache Wicket automatically

This article documents an Apache Wicket solution to automatically save drafts of user input in the background using ajax POST requests to the server. The stateless nature of <textarea> form inputs introduces usability and reliability problems when users require a long time to fill them in. Consider some common scenarios, such as a user’s web [...]

Install python MySQLdb module

MacOS This Stack Overflow article perfectly documents the necessary steps and works with python 2.7. I have also saved these instructions in PDF format.

MacOS Command Prompt and vi Customizations

This is my custom command prompt configuration. Command Line First, install the far better iTerm. Now edit /etc/profile and add the following. This can alternately be added to ~/.profile to make the change local only to the current user. # add vi to the command line for previous command lookups set -o vi # remove [...]

MacOS Keyboard Shortcut Customizations

Custom keyboard shortcuts that I find useful. Open System Preferences > Keyboard > Shortcuts > App Shortcuts. To maximize the currently focused window, add the following. Menu Title: Zoom Keyboard Shortcut: Control + Option + ⌘ + M It’s also useful to be able to tab through the buttons in dialogs (e.g., an OK/Cancel modal [...]

An efficient typeahead/autocomplete data structure and algorithm

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 [...]