Archive for July, 2010

Firefox 4 beta 1: A very quick first look

Thursday, July 22nd, 2010

There’s not much wrong with the first beta release of Firefox. It performs well, never crashed during several days of use, and, thanks to changes in the menu bar, is much better at using available screen real estate.  Unfortunately, it’s not an everyday-use browser. Yet.

It’s the lack of compatible extensions that keep this from being an everday-use browser.  It has become very apparent just how much I use extensions in my day-to-day use of Firefox.  Between Firebug, Greasemonkey, Read It Later and Xmarks, I can’t do more than just review how my sites look and perform in the new browser. The good news is that NoScript and AdBlock Plus *are* available now, so it’s not you’re browsing unprotected.

Most of the changes just take a bit of getting used to. Finding where the menu bar went and how to get there was a bit of a challenge, but, frankly, there aren’t many daily-use things in the menu bar that are not in the Firefox drop down menu.

During the time I used beta 1, I found only one rendering glitch, and that was with the pan control in the aerial view feature of Google Maps. There appeared to be a ‘ghost’ control behind the main control, and as a result, I couldn’t move to a westerly view. Closing the browser and starting over seemed to take care of the problem, though.

It appears as if there are new features still on the horizon; the extensions page says to ‘watch for something new’. And while eliminating dialog boxes was a focus of this release, several still remain, including the error console. An example of where a dialog box went away is the extensions page. Expect to see more of that in the upcoming beta releases.

Implementing an intersect in MySQL

Monday, July 19th, 2010

For those of you looking for information on the TV show “Chuck“, this is not for you. If you don’t understand what that means, then this might be for you.  Standard SQL provides a construct called union that combines the contents of two queries, which acts as a logical OR operation against two or more datasets. However, I recently found myself in the need of the similar functionality, but with an AND operation. SQL Server provides a construct called ‘intersect‘ which does just that, but it’s not ANSI SQL, and, since I was using MySQL, that didn’t help me.  I did find a way to get the data I needed, however, by using a combination of grouping and the having clause.

Here’s the problem: I had two tables of data that formed what was a many-to-many relationship (a map table was the third table). The first table contained generic data, and the second table contained free-form meta information about the records in the first table. For the purpose of illustration, imagine a set of records with a name, address and astrological sign; each one of those records could have 1 or more free-form meta fields attached to it:

My assignment was to select all records in table a that matched all of the free-form meta fields submitted from a user.  At first this seemed simple:

select * from a, b, abmap where a.id = abmap.a_id and abmap.b_id = b.id and b.meta in ('meta1', 'meta2', 'meta3');

Unfortunately, this doesn’t implement an AND; it would include records from table a that had either 1 or 2 of the requested meta values in addition to having all three.  I was looking for something like:

select all records that have meta=meta1 AND meta=meta2 AND meta=meta3

What I needed to do was to group on a field I knew had unique values in table a (using the example case, I used ‘name’), then use the having clause to count the number of rows for every name in the result set. If the number of returned rows for any given name matches the number of meta values provided by the user, the record is considered a match.

select a.* from a, b, abmap where a.id = abmap.a_id and abmap.b_id = b.id and b.meta in ('meta1','meta2','meta3') group by a.name having count(a.name) = 3;

The count function normally returns the number of rows in the query, but since the query has been grouped by the name column, count returns the number of rows in each group. Since the user had specified three different meta values, I wanted to find groups with exactly three records. By using this query, you would get all records from table a that had the values ‘meta1′, ‘meta2′ and ‘meta3′ attached to it through abmap, no more, no less.

Finding the error console in Firefox 4 beta…and more!

Wednesday, July 7th, 2010

firefox logoThe Firefox 4 beta is out, and I’ve run it through the gamut of applications that I’ve written and somewhat responsible for (good news: everything works!), but I ran into a bit of a problem trying to find the JavaScript (or error) console. The reason for this is that Firefox 4 no longer has a menu bar by default, but instead has a single Firefox drop down menu in the upper left of the Firefox window.  I like this, because it gives more room for what you’re on the Internet for: content. Since the advent of tabs and toolbars, content has been continually having it’s real estate stolen, so it’s good to see content area reclamation taking place.

But without the menu bar, there’s no (visible) way of getting to the JavaScript console. However, it’s still possible to get the menu bar to appear temporarily by pressing the alt key; the tab area pushes down, and exposes a menu bar near the top of the screen. Once the menu bar appears, you can go to Tools -> Error Console to get your JavaScript debug on. While looking at the Tools menu, remember that the key combination Ctrl-Shift-J will bring up the console directly.

If you want the menu bar back permanently, go to the Firefox drop down menu, select Customize, then check Menu Bar, and the menu bar stays, leaving the JavaScript console at your beck and call.

BUT WAIT!

The Error Console is old news. It’s soooo 2008. Now all the cool kids are using the Heads-Up Display, which, from what I’ve seen, is the Error Console on steroids.  There are more types of events to filter, including DOM mutation (which is great for AJAX debugging). Check it out.

How to fix the font in the MySQL Workbench editor

Tuesday, July 6th, 2010

Just ran into an annoying little problem using the version 5.1.12 of MySQL Workbench: the font used in the SQL editor is really small, and there’s no way to change it.  The preferences dialog shows you what the font is, but it’s a text field, and even though you can type in it, it appears to be a read-only field.

To fix it, go old school and edit the configuration file.  On Linux, it’s in your home directory in .mysql/workbench/wb_options.txt. Be sure to quit MySQL Workbench before editing the config file to avoid having your work overwritten.

Once you’ve opened the file, look for the key workbench.general.Editor:Font, and increase the font size to something usable.  I chose 11, but some may still find that too small.

Save the file, then start MySQL workbench.  You should now be able to read what you’re writing in the editor.