Sunday, January 31, 2010

Truncate all Tables in a MySQL Database Revisited

Since this old post still manages to get a fair number of hits I thought I should fix it up to encourage people to not reveal their MySQL passwords in history logs and process lists by entering it on the command line. The new version uses getopts for parsing command line options. If you pass in "-p", it will prompt you for your database password for each mysql command. If you really want the old bad behavior then "-P password" will do the trick. Enjoy:



It is also possible to put your password in your my.cnf file to have it picked up automatically. You can read more about MySQL password for version 5.4 security here.

Sunday, January 10, 2010

Java enum and Static Variables

I've been moving back into the world of Java after some time with Ruby...surprisingly (to me anyway) Java enums don't have access to static variables within the enum in the enum constructor. For example, this will fail to compile with an illegal forward reference when attempting to use the static constant:



I haven't found a work around for this that I am comfortable with. Defining the static constants elsewhere seems quite ugly.

The same problem occurs if you want to set up a static cache during construction as well. This can be worked around with a static initializer:

Sunday, July 12, 2009

Searching for Wildcard Characters in SQL

Been a while - a quick flush...you may have a need to search for the wildcard characters "_" and "%". When that happens you need to know how to escape them. This has slightly different behavior for different database products. MySQL and SQL Server do work the same way, however, if you stick to using the ESCAPE clause.

Friday, July 03, 2009

No Peeking in the Javascript Deque

Another (previous) take on the Javascript Deque with more of a Crockford creation style preventing messing with the Deque's internals. Create one without using new - "var d = deque();", enjoy:

Wednesday, July 01, 2009

Javascript Deque

Doubly ended queue code is just a whole lot cleaner if you go with dummy head and tail nodes to avoid special cases. I put together this Javascript example: A Javascript array has the methods available (push(), pop(), shift(), unshift()) to be used as a deque but of course being an array you shouldn't be adding and removing from anywhere but the tail end if you need top performance. The following provides for a comparison between my deque and a regular Javascript array for adding and removing items from the head or tail of the data structure.
Items:
array dequeue
head tail

Tuesday, June 23, 2009

JavaScript InfoVis Toolkit

The JavaScript InfoVis Toolkit is another example of a library exploiting Canvas technology. I put together a small demo Rails application that uses the toolkit to provide a dynamic tree view of the Rails application directory structure.

Monday, June 22, 2009

Don't Miss Aloha on Rails!



You don't want to miss the Hawaii Ruby On Rails Conference - Waikiki, Oahu, Hawaii - October 5-6 2009. The speaker list is impressive and still growing. The venue is awesome and is only a short (really short!!!) walk from Waikiki beach. The economic downturn is making flights to Hawaii very reasonable right now.

This conference is being primarily organized by Seth Ladd, a Honolulu based RoR developer and great co-worker of mine. There is an Aloha On Rail Blog featuring the latest information. The latest post features another great co-worker of mine, Honolulu Hacker Kevin English in a clip on why you should come to Aloha on Rails.

Why Aloha on Rails???

  • mingle with a group of very talented developers
  • gain insights on the latest technologies and techniques
  • re-charge your batteries
  • reward yourself!

This is a no brainer - register now!