Computery

TIP: Apache rewrite rules forgetting stuff

Tags: 

On a side project I'm working on they're using Apache mod_rewrite rules to turn ugly page addresses into pretty ones, e.g.:

RewriteRule widget-(.*)\.htm$ widget.php?id=$1

Nice goal and in general it works well. There was a problem, though, when they started doing this the SAJAX AJAX fancy stuff I wrote stopped working. A few thousand hair and some time later I worked out that one very simple keyword was missing from the rewrite rules, the %{QUERY_STRING} keyword to retain all of the extra fields passed in by SAJAX, e.g.:

RewriteRule widget-(.*)\.htm$ widget.php?id=$1&%{QUERY_STRING}

Also, note the extra ampersand in there before the keyword, you need this to separate the extra values from the one you're passing in from the widget-somat.htm address. Et voila!

MySQL Tip: phpMyAdmin export filename

Tags: 

A quick time for any users for phpMyAdmin and MySQL.

When you backup your database using phpMyAdmin, an "export" in their terminology, by default it names the file simply databasename.txt, e.g. damien_blog.txt. If you do regular backups this becomes a slight hassle as each time you have to rename the file to something more useful, and decide if you want to name it after the date, or add a version number (e.g. "database_backup_5.txt"), etc.

There's an easier way to take care of this. Instead of letting phpMyAdmin name the backup file after the database, have it automatically add the date to the filename too. Then, when you download the file you'll be able to list them in order, oldest through newest, and never wonder whether you named the file correctly the last time, or which one is newer.

To do so is quite easy, simply go to the Export page in phpMyAdmin, change the Save as file filename template to __DB___%Y%m%d%H%i and your backup will now be named e.g. damien_blog_200602131315.txt. What makes this even more useful is if you click the option labelled remember template, that way you'll never have to remember this again, simply click it and all backups that you do from then on (from that computer and that web browser) will be named accordingly.

Note that the date is listed as year, month, day, hour and then minute, which when you have several files listed in a directory one after the other makes it really easy to see the files in the correct order, rather than trying do list them with e.g. the European date format of day-month-year or the American format of month-day-year.

Update: Thanks to reader Jörg for pointing out that the last part of the string should have been %i rather than %m to output the minutes.

Best keyboard ever?

Tags: 

Well, for under $50 anyway...

Kensington Comfort Type Multimedia Keyboard

Recently to match the new PC upgrade we did I picked up a new keyboard after seeing one at CompUSA. Its made by Kensington, a company that has been around for what seems like forever (at least in IT-world terms, i.e. 15-20 years) and at first glance seems the same as any other on the market with its multimedia keys and fairly generic layout. However, after laying your fingers on its keys you notice something different - the keys are slanted!

Those kooky folks at Kensington must have spent way too much time looking over people's shoulders while typing. It seems they noticed that when most people type their hands tend to angle away from each other with the backs of the hands pointing over the typists shoulders and fingers pointing inwards. Go put your hands on a keyboard, let them rest and see what way they lie. So they took this knowledge and designed a keyboard that slants in the direction your fingers are pointing.

The first time I saw the keyboard it seemed a bit strange but typing on it for a few seconds, even not plugged into anything, I could immediately tell that it fit my natural typing position better than the generic un-slanted keyboard, and so the next time I was at the store I got one.

The only negative side I can see is that the back-slash / pipe key, which is usually above the enter key, is positioned beneath the enter key. This has the awkward effect of both having to re-train yourself to a new location for a key often used by geeks (i.e. me), and also making the right shift key narrower. I'll live, but I wish they left it where it should be.

Lastly it must be mentioned that this is a PS/2 keyboard, i.e. that little round connector which has been standard on PCs for ten years or so. Personally I think that it should be USB as standard, USB has been on PCs since the late '90s and there's no excuse these days for not shipping devices that are USB compatible, at the very least bundling an adapter. Heck, our new computer has about ten USB connectors, never mind using a USB hub.

Kensington sell multiple varieties of the keyboard, with this one ranking at the $20 mark with two others available without the multimedia keys - one beige PS/2-only keyboard for $15 and a black PS/2-USB one for $20.

So next time you are looking for a keyboard I suggest seeking one out and giving it a spin, you might just like it.

Pages

Subscribe to Computery