Think before you commit

Posted by Kevin Owocki | Posted in Technology | Posted on 21-11-2009

Version control is important, oh so important for managing changes to your codebase. Whether you’re a solo developer, or a team, you NEED to be able to track the evolution of your code.

Tracking down changes to code is one of the most important things I do, day to day. Though, sometimes it’s way too hard to reverse engineer a developers intentions if their commits messages or changes sets are opaque. Other times, it’s hard to match a specific commit to business requirements

I think it’s time to introduce some best practices for ensuring useful commits:

  • Match the commit message to your requirement story title. When I’m committing a change for a story in our requirements management system called ‘Inbox management iteration 1′, my commit message will likely be ‘Inbox management iteration 1 – Commit #1, {brief search-friendly description of features}’
  • Make small atomic commits A commit should be one cohesive logical unit. I’ve found that by making small, granular commits every time I complete something, it’s must easier to reverse-engineer my intent later.
  • Compile before you commit It sounds so basic, but sometimes code gets committed with syntax errors.
  • Test before you commit Again, sometimes code gets committed that hasn’t been thoroughly tested. This is extremely important for changes to foundational pieces of a codebase.
  • Compare via diff before you commit Comparing via diff is a great way to view what you are actually changing from a higher-level view. It’s useful to make sure what you’re changing makes sense to you and your team, if they ever have to come back to it.

If you and your team follow best practices for your commits, then it can save everyone a great amount of time and effort.

Does your commit process need improvement? Do you think before you commit? Leave a comment below or via twitter here.

How to fix INSERT DELAYED Delayed_errors in MySQL.

Posted by Kevin Owocki | Posted in coding tips | Posted on 19-11-2009

I’m posting this mainly because I had such a hard time fixing this (and Google didn’t seem to have any articles on how to fix it). If you are not technical, or you don’t work heavily with MySQL, then you should probably move on…

If you are trying to add INSERT DELAYED queries to your application (whether to save time on table inserts or to speed up your application) , and your rows are not getting inserted into your table, then you should check out your global status and variables:


mysql> show status LIKE '%Delay%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| Delayed_errors | xxxxx |
| Delayed_insert_threads | xxxx |
| Delayed_writes | xxxx |
| Not_flushed_delayed_rows | xxxx |
+--------------------------+-------+
4 rows in set (0.00 sec)

mysql> show variables like '%delay%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| delay_key_write | xxx |
| delayed_insert_limit | xxx |
| delayed_insert_timeout | xxx |
| delayed_queue_size | xxx |
| innodb_thread_sleep_delay | xxxx |
| max_delayed_threads | xxx |
| max_insert_delayed_threads | xxx |
+----------------------------+-------+
7 rows in set (0.00 sec)

If you are seeing that Delayed_errors is being incremented, and your query works without the ‘Delayed’ element of the statement, then you might want to look into your table structure. Something about having an ‘auto_increment’ table and replication enabled caused my delayed inserts to fail.

Turns out if you add:

ON DUPLICATE KEY UPDATE ID=ID+1;

to the end of

INSERT DELAYED INTO `Table` VALUES (NULL, 'val', 'val', 'val', 'val', 'val', 'val', 'val', 'val' , 'val');

to get

INSERT DELAYED INTO `Table` VALUES (NULL, 'val', 'val', 'val', 'val', 'val', 'val', 'val', 'val' , 'val') ON DUPLICATE KEY UPDATE ID=ID+1;

it works. Turns out Mysql has a problem with duplicate keys on the autoincremented ‘ID’ column of the table.

Did you find this useful? Extremely boring? Leave a comment and let me know:

How much is a themed Google logo worth?

Posted by Kevin Owocki | Posted in Technology | Posted on 16-11-2009

Google periodically updates their corporate logo on their homepage with a themed logo. Typically, this themed logo will coincide with a current event or news item in the country they launch the logo in. For example, in USA, the Google.com homepage over the last few weeks, has had themed logos celebrating both the 40th anniversary of the first episode of Sesame Street and the anniversary of the invention of the bar code.

It’s interesting to me that if you click on the themed logo, you’ll be taken to the search results for your logo, ie. ‘Sesame Street’, or ‘Bar code’, respectively. I thought it’d be interesting to dig a little into how much of a traffic boost websites on the first page the google results for these queries got during this time.

Case 1: 40th anniversary of Sesame Street.

The sesame street logos went live on Nov 4th and ran for a few days.

There’s a huge jump in searches related to sesame street during this timeframe.
SesameStreetGoogleTrends

SesameStreet.org is on the front page of search results for the ‘Sesame Street’ query. Their traffic has been climbing month-by-month. Though it’s too early to tell, I’d be willing to bet the Unique Visitor count is going to skyrocket in November!

Case 2: Anniversary of the invention of the Bar Code.

Google launched this bar code logo on Oct 7th 2009.

And…. the jump in volume for ‘bar code’ searches associated with the logo launch:
BarCodeGoogleTrends

BarcodesInc.com is on the first page of Google search results for the query ‘Bar Code’. They got quite a jump in traffic for October!

UPDATE 11/16/2009: Jeff Powers, co-founder of Occipital (the company that makes the #1 bar code scanning app in the iPhone app store, RedLaser), left a comment noting that they got about a 1000 user bump on Oct 7th, a bump he attributes mostly to the awareness generated by the Google logo.

————–

I wonder how much it’d be worth to a private company to “buy” a themed google logo for a day. In a world where media and advertising industries are being revolutionized, I’d be willing to bet a logo campaign with Google would be worth quite a bit.

Again, you can see the entire collection of themed logos at google.com.