Monthly Archives: November 2007

Pictures

I think my blog is really boring because it doesn’t have any pictures.  I’m jealous of those people that get themselves to carry their camera and take random pictures of interesting stuff during their day.  My brother Bob was doing a picture a day project, but that seems to have died.  What I’d like to do, though, is capture a photo that complements whatever I happen to be writing about, as opposed to the picture being the star of the show.  I have a really nice camera, but it is too big to carry around all the time.  If you feel like getting me a smaller one, have a visit to my Amazon wish list and pick one up :).

Taking photos in Java with the Blackberry

According to this press release, RIM has released the APIs needed to take photos with the Blackberry camera in Java apps.  As far as I have figured out, they have enabled the API to start the camera app, but not an API to listen for new photos.  That isn’t particularly horrible, because you can use the File Connection API to open the Blackberry filesystem and monitor for new photos.  The only tricky part is knowing when the camera app has relinquished control back to your app, so you can start looking for the new photos.

Another post about my favorite database

Relational databases are really cool. When you get experienced with them, you can leverage all sorts of features to make sure your data is solid. A good database schema will provide a good check against buggy code trying to mess up your data. One of my favorite ways to enforce integrity is the usage of NOT NULL constraints. I recently added some to a MySQL database I’m working on, and I noticed something unusual…

mysql> alter table SERVICES add SERVICE_KEY varchar(64) NOT NULL UNIQUE;
Query OK, 1 row affected (0.16 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> describe SERVICES;
+------------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+---------------+------+-----+---------+----------------+
| SERVICE_ID | bigint(20) | NO | PRI | NULL | auto_increment |
| DESCRIPTION | varchar(128) | YES | | NULL | |
| COMMENTS | varchar(64) | YES | | NULL | |
| ACTIVE | varchar(3) | YES | | NULL | |
| CREATED_BY | varchar(128) | YES | | NULL | |
| CREATED_DATE | datetime | YES | | NULL | |
| UPDATED_BY | varchar(128) | YES | | NULL | |
| UPDATED_DATE | datetime | YES | | NULL | |
| TYPE | varchar(4) | YES | | NULL | |
| URL | varchar(1024) | YES | | NULL | |
| MAX_TRAN_THREADS | smallint(6) | YES | | NULL | |
| MAX_SYNC_THREADS | smallint(6) | YES | | NULL | |
| SERVICE_KEY | varchar(64) | NO | UNI | | |
+------------------+---------------+------+-----+---------+----------------+

As you may notice, the default value is somewhat nebulous on this new column. Normally the default will show NULL, which is good. In this case, it looks like it is either “nothing” which I would equate to NULL, or ”, which is horrible because it breaks the whole purpose of having the constraint. Since I trust MySQL to generally do the wrong thing, I test it:

mysql> insert into SERVICES (SERVICE_ID) values (NULL);
Query OK, 1 row affected, 1 warning (0.00 sec)

And of course, it is taking my null SERVICE_KEY value and turning it into ”. So now, if my app is broken and trying to insert null into SERVICE_KEY, MySQL will save the day and “fix” the data, completely eliminating any errors from being produced that would have revealed the bug in my code.

To quote the famous fashion designer Mugatu, I feel like I’m taking crazy pills! Everyone seems to love MySQL, but it seems completely obvious to me that it is not even a candidate to be considered when writing anything moderately serious.

A2DP in Leopard

One of the features I was looking forward to in Leopard is support for Stereo Bluetooth headphones. I am happy to report that it works, and the UI is much better than ones I’ve used in Windows (obviously, right?). Unfortunately, I seem to pick up a lot of interference. When I first tried them at home, I didn’t notice it, so there might just be a lot of interference in my office on campus. I can see like 5 wireless networks, so it makes sense. I wonder if I’d have the same problem with a PC. Maybe I should build a tinfoil box to sit in.