svn pre-commit & post-commit hooks

I have to say I love subversion (svn) hooks.  I’ve only been playing around with the concept fairly recently and I’m surprised that I lasted this long without them.  I wanted to take a few minutes and share my favorite ways of using them.  As well as a few that I don’t use but I think could be pretty helpful.

Before we keep going, if you don’t know what svn hooks are you can read up on them at http://svnbook.red-bean.com/en/1.1/ch05s02.html.  svnbook.red-bean.com is my reference site of choice whenever I need to look up a svn command.

My #1, all-time, greatest in the world, bestest favorite is a svn pre-commit hook to syntax check my PHP code.  There is nothing I hate more than a developer checking in code with syntax errors and breaking qa or stage or even, god-forbid, production.  It’s as easy as setting up the hook to run a script that calls “/path/to/php -l /path/to/file.php” and on failure reject the commit.  This way code that has syntax errors will never make it into SVN.  Now if only open-source projects like ZendFramework did something like this before releasing their code.  To be fair, the syntax errors are in their documentation not in the /library/ files but that’s still pretty dumb & annoying.

Another nice way to use a post-commit hook is to run something like PHP_CodeSniffer against the commit.  CodeSniffer is an awesome PEAR package that scans your file and flags coding standards violations.  It comes pre-packaged with sniffers for the PHPCS, PEAR, Squiz and  Zend.  Set it up to run and if it finds coding standard violations you can have the hook send out nasty little blame messages.  ;)  This isn’t something that I’d want to run on pre-commit just in case you really need to get something into production NOW.  But if I hosted an open source project, I’d consider it.

Having minified JavaScript & CSS has become the standard way of serving JS & CSS.  But who really wants to take the time to minify or combine them?  Once again, enter svn hooks.  One of the developers set this up for GameSpot and it has been working great!  Basically it checks the commits against a defined naming standard, file.src.js or file.src.css, and then runs the YUI! Compressor on it and commits in file.min.(js|css).  He also made it check a global.conf in the file’s directory so it came mash up smaller js files into a global.min.js so we serve one file instead of ten.

Of course, let’s not forget about what is probably the most common svn hook; the post-commit email hook.  I like svnmailer better than mailer.py that comes with svn by default.  I think it’s easier to configure/change and to setup rules for how you want the emails to look or where to go.

If you’re using a ticket tracking system like Bugzilla or Trac that doesn’t have its own way of peeking into svn (like JIRA can with this plugin) you can write a post-commit hook to update the ticket when something is committed.  You can see how Trac recommends you do it at http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook.

To help you on the way to creating your own svn hooks, tigris has a few hooks that are distributed with svn.  They can be quite helpful so you should take a look at them.

Posted under PHP, Tips & Tricks

This post was written by on March 7, 2009

Tags: , , , ,

Goodbye Paul Harvey

As you may already know, American icon Paul Harvey died on Saturday. I’ve always said to people, “Why should I care about celebrities?” I never thought I’d care a great deal about the happenings to any of them. Well it turns out I was wrong. It came as a great surprise to me when I actually shed a tear (only one though) when I heard over the weekend that Paul Harvey passed away. It is an even greater surprise that I still feel a bit sad whenever I hear a new tribute or story about the man. As it turns out, I’m really going to miss listening to him on the radio.

I have disagreed with Paul Harvey a lot over the years (in my own thoughts anyway), mostly about the way he reported medical stories without questioning the validity of the data or his reports on the war in Iraq & against terrorism. But even with that, I have always liked his programs. When I used to drive to work I’d try and time my commute so I could catch “The Rest of the Story” (one of my favorite programs) on KGO. I still remember his story about the penny and the Chicago newspaper advertiser who started the 99 is less than 100 trend (because people feel that $9.99 is a lot less than $10) because he wanted to sell his paper for a penny instead of a nickle. I’d even occasionally take lunch around his noon program “News & Comment.”

Being on the radio for over 60 years, even after he turned 90, Paul Harvey became a radio legend. According to his Wikipedia entry, Paul Harvey’s programs were carried on over 1,200 radio stations, 400 Armed Forces Network stations and 300 newspapers. With that sort of exposure, his passing will have a profound impact and noticeable loss to a large and diverse group of people. I’m sure he will be sorely missed. An additional note of merit, Paul Harvey was the recipient of the Presidential Medal of Freedom, America’s highest civilian award.

As you might also know, his son, Paul Harvey Jr, has been filling in for him over the last several years as he dealt illness and the loss of his wife. It is good to hear that Paul Harvey Jr will be continuing in his father’s footsteps and keeping the programs going.

Rest in peace Paul Harvey. I, as well as a nation, mourn your passing. In the words of Paul Harvey himself, “Good day.”

P.S. If you’d like to leave his family your condolence for his family you can do so at http://abcrn.com/harvey/contact/

Posted under News, opinion

This post was written by on March 3, 2009

Tags:

Twitter Updates for 2009-03-06

  • Week 1 results: 6lbs. Not bad. Week 2 goals include hitting the gym more often. #
  • I’m awake but I haven’t made it out of bed yet. I’ve been on PTO for a week and last night was the only night I couldn’t sleep. Coincidence? #
  • @mager but mall cop wasn’t that great. Funny but not incredibly so. #
  • Breakfast at 3 cooks cafe in Petaluma. Best breakfast place I’ve ever been. #
  • Day 5: pretty good. Under the calories but didn’t make the gym. I’m optimistic this will stick this time. #
  • Talked to Denise & she said the helicopters overflew her school in Lafayette as well. Interesting… Onto news searches to find out more #
  • @gpbmike At first I thought one was crashing. Then surprisingly enough, there was a red dawn moment. I wish I got a picture of them. in reply to gpbmike #
  • Got a pic of the small helicopter that followed a few min later. I can still hear the transports in the distance. #
  • wow! Two large dual prop helicopters just overflew my house at like 300ft. Loud suckers. #
  • fail. no go on getting tidy installed on my laptop in time for the presentation. :( sucks to be me. #
  • wtf, now the laptop is asking me for the admin password to connect to a wireless network. arg!!! #
  • So very annoyed with my company installed laptop. #
  • took me forever to figure out which building on the sun campus is the ballroom. For those confused too (incl the security guard) its bldng 7 #
  • getting ready to leave for tonight’s #gbalampmeetup. hopefully i won’t get lost this time. #
  • Try to code up some examples before tonight’s meetup. I have code for how to use tidy, but nothing for why other methods fail. :( #
  • Day 4: Going pretty good. I’ve made the gym 3 out of the last 4 days. woot! Unfortunately pizza for dinner at the #gbalampmeetup #
  • Fail: some replies are missing that were there earlier tonight. Yes they are still on the sender’s tweets page. :( #
  • Day 3: dinner == fail. :( calories are close (within 25 of limit) but that’s not good. I’ll do better tomorrow. #
  • It’s hard to diet when there is a ton of snack foods around… Thank goodness dinner is almost ready. Smells yummy. #
  • @gpbmike I was using both for a bit but I found LiveStrong’s had more of the foods I eat. in reply to gpbmike #
  • @gpbmike I’m using livestrong.com’s iPhone app. So far the only thing I don’t like is that I can’t create a “meal” that combines ingredients in reply to gpbmike #
  • Day 3: so far so good. not eating too much & I hit the gym. Dinner is going to be iffy though. I think I’ll still be under though. #
  • Working on my presentation again for the #gbalampmeetup #
  • Cooking dinner @ Denise’s grandpa’s house. It’s a spicy pork & rice dish called “black death” it’s one of my favs. :) #
  • If it wasn’t for Akismet my blog would be filled with animal porn comments. I’m not sure why spammers think animal porn is a good match…. #
  • @larrrk you look like you were sleeping at the last #sfphpmeetup http://www.flickr.com/photos/michaeltougeron/3291454358/ :) #

Powered by Twitter Tools.

Posted under Twitter

This post was written by on February 25, 2009

Tags: ,

Memcached Q&A and SEO for Developers – SF PHP Meetup Feb 12th, 2009

This month the SF PHP Meetup has two great speakers lined up. The first will be the intro talk/Q&A given by Dormando on memcached. This will be less of a talk than an interactive Q&A session about memcached.

For the main presentation David Gomel, Senior Program Manager leading SEO within CBS Interactive, will speak to us about SEO in a Web 2.0 world. The session will cover many of the important SEO issues that involve front and back-end engineers on a daily basis. Many of the decisions that tech folks make have the potential to materially impact search engine traffic. Even if you have been to a similar talk in the past, you should consider attending as we will be discussing topics that are frequently evolving. Please bring questions!

Topics will include:

  • HTML fundamentals
  • CSS Usage
  • JavaScript/Flash/Ajax
  • Graceful Degradation
  • Multimedia Content
  • Duplicate Content
  • Redirection
  • URLs
  • Bot Traffic
  • Robots.txt

…And More!

David Gomel is the Senior Program Manager leading SEO within CBS Interactive. He is responsible for SEO knowledge sharing and training within the company.


When: 6:30pm Thursday Feb 12th, 2009
Where: CBSi – 235 2nd Street San Francisco, CA
RSVP: http://www.meetup.com/sf-php/calendar/9230626/


Agenda:
6:30 – 7:00 — Doors open/general socializing & food
7:00 – 7:30 — Intro talk on memcached by Dormando
7:30 – 8:30 — Main presentation by David Gomel on SEO.
8:30 – 9:00 — Main presentation Q&A
9:00 – 10:00 — General discussion/Q&A/networking/etc.
10:00ish — end of group

Posted under Events, Internet, Tips & Tricks

This post was written by on February 4, 2009

Tags: ,

Introducing the Tungsten Replicator for MySQL – SF MySQL Meetup Feb 2nd, 2009

Almost everyone I’ve ever talked to about MySQL has some complaint or another about its replication.  So when Robert Hodges, CTO of Continuent, offered to speak about the  Tungsten Replicator open source project at the February 2nd SF MySQL meetup I was all for it!  Now I know what you are thinking… “Not another sales pitch!”  But have no fear, Robert is one hell of a smart guy and is much more of a techie than a CTO (in a good way).  I remember one sales call where Robert came to CNET to talk about Continuent’s clustering software and we ended up spending more time talking databases in general than about the product.  :)

So if you’re in the SF area on Monday Feb 2nd, 2009, stop by the CBSi building and listen in.


When: 6:30pm Monday Feb 2nd, 2009
Where: CBSi – 235 2nd Street San Francisco, CA
RSVP: http://mysql.meetup.com/30/calendar/9455586/


Description from the SF MySQL Meetup calendar:

Tungsten Replicator is a new open source project for database replication. It offers MySQL to Oracle replication, robust handling of master failures, extremely flexible topologies, and an extensible architecture that allows you to add your own replication features if you don’t find them there already. I’ll describe why MySQL needs more replication, show the product architecture, describe some of the problems it solves, and demonstrate the replicator in action. Finally, we’ll play “stump the chump” where you can present your replication problem and I’ll describe how our replicator handles it. Whether you have a tricky replication problem or are just curious about the subject, please join us. This is a very technical presentation that should be of interest to all true MySQL fans.

More information on Tungsten Replicator: http://www.continuent.com/community/tungsten-replicator

Posted under Events, mysql, Technology

This post was written by on January 24, 2009

Tags: , , , ,