thoughts from brian samson

A flag pin for your Mac

I was reading this text file on my MacBook the other day that had some strange copy/paste behavior. It turns out this was because of one of the dozens of “space” characters in Unicode, one of which was being interpreted as a linefeed in some editors and as a space in others. So I went to the Edit Menu -> Special Characters (which is in almost every cocoa app) to check it out. In the end I figured out how to replace my special character with a normal one and went about my business, only to later notice activating that menu had the side effect of enabling the “Input Menu” in my title bar. If you are in America like me, the icon for this menu is an awesome American flag logo. So now even your Mac can have its very own flag lapel pin!

Mac flag pin

(The “Input Menu” is available via System Preferences -> International -> Input menu)

All politics, all the time

I have a tendency to argue politics with anyone who will take up the subject. My friend Simmons is one of these people, and we have spirited internet discussions on a regular basis. As a result, we’ve started a political blog you can go read at: 1idiot1genius.blogspot.com. The name comes from the fact that we usually believe the other is an idiot, but I’ll leave it to the readers to decide for yourselves. So if you feel like arguing on the internet, head on over!

MySQL and BLOB sizes

I’m doing a ruby on rails project with MySQL that needs to store some images, and I thought to use the database. However MySQL’s default blob size is only 64K, so I wanted to use their LONGBLOB column instead. No big deal, and in fact they will automatically detect which of their myriad BLOB types to use based on the length of a BLOB column. Nice!

Now for a quick pop quiz. One of the following statements is a syntax error from MySQL. Can you guess which one?

A) CREATE TABLE test (id int, data blob(2147483647));

B) CREATE TABLE test (id int, data blob(2147483648));

C) Neither, they are almost exactly the same, how could one be a syntax error?

If you guessed ‘C’ congratulations, you are smarter than (at least one) MySQL developer. But you lose the quiz, because he correct answer is ‘B’, which generates the following error:


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘2147483648))’ at line 1

I deciphered from their cryptic documentation that LONGBLOB columns can have up 2^32 -1 bytes (almost 2 gigabytes), and apparently if you enter a number larger than that it’s invalid syntax. Thanks for wasting that hour of my life, MySQL.

And by the way, if you need to create a LONGBLOB column in a Ruby on Rails ActiveRecord migration, use this line:

add_column :table_name, :column_name, :binary, :limit => (2.gigabytes - 1) #mysql is terrible software

Clouds

After stuffing my face with ribs on July 4th I grabbed this shot of some clouds coming as the sun started to set.