SVN Deploy Script
26 November 2010

Having worked a bit with Ruby on Rails, I've come to appreciate the Capistrano deploy method. Since I also work in PHP and deploy to Linux I recently wrote a bash script to export from SVN to a timestamp named directory with a symbolic link for the webroot.

This allows for very quick code rollbacks by changing the symlink to point to the last working version if a deployment goes wrong. The script allows checking out from trunk or specifying a branch, tag or revision number.

Usage:

#./svndeploy 
#./svndeploy -b [branchname]
#./svndeploy -t [tagname]
#./svndeploy -r [revision number]

The script should live in the directory below the webroot (ie the same directory as the Apache docroot for the specific site).

Download it here

Update: Now with an rsync command to synchronized with the previous release in case there were any assets not under SVN control.

Query Optimization
11 November 2010

I have a certain weekly report I run at work that has become increasingly slow as the tables continue to grow. I knew why this was happening and even knew where the problem lay - a nested select, but it was never high on my priority list. Having some time recently, and becoming increasingly annoyed at the length of time it took this one report to run, I had a go at making it better.

The query itself consisted of a union of two select statements. One of the unions had a curious left join:

select t1.number from table1
left join table2 t2 on t2.number = t1.number
where t2.number is null

The other side of the union used a nested select to achieve the same effect, which was to get all the rows out of table1 for which an entry did not exist in table2.

select t1.number from table1 t1
where t1.number not in (select number from table2)

The left join with a null where clause is an ingenious method to perform a "not in" statement. The nested select was slowing things exponentially as the tables grew. Implementing the join method on the other side of the union cut my query time from 35 seconds to 2.5 seconds. 94% optimization with that one little trick.

 

Website Monitor
13 October 2010

A month later, and my Website Monitor Android app is published and gone through a few iterations. I must admit that it's fun to watch the download numbers climb and the ratings come in. The Website Monitor has just passed 50 downloads, but I don't expect it to become very popular as it's a tool directed specifically at webmasters. My Binary Time widget has seen moderate success with 350+ downloads. October 10, 2010 saw a surge due to the date being binary day (10.10.10). I hadn't planned for this but the release was timely. 

I'm now toying with extending the Website Monitor to a paid version called Server Monitor with the addition of monitoring other ports as well as allowing server admins to write custom scripts to report failures or any other conditions they would want to be alerted about. I would also make the application more configurable as right now there are no customizations.

I'm really enjoying Android development; however, it is hard to squeeze time in between my regular job, being a dad and husband. With our move coming up shortly, I expect I will have even less time until we get settled in. That said, if anyone has any ideas for applications they want to see on their Android phone, let me know!

Android App Coming Along
14 September 2010

AndroidMy Android app is really coming along. I finally got my widget working together with the app. One more small detail of making it more configurable and I might even put it on the Market!

Tags


Fatal error: Uncaught Error: Undefined constant "Math" in /home/sgreimer/stevenreimer.com/includes/classes/TagCloud.class.php:188 Stack trace: #0 /home/sgreimer/stevenreimer.com/templates/_includes/sidebar.php(52): TagCloud->showCloud() #1 /home/sgreimer/stevenreimer.com/templates/index.tpl.php(25): include('/home/sgreimer/...') #2 /home/sgreimer/stevenreimer.com/includes/Page.class.php(412): include('/home/sgreimer/...') #3 /home/sgreimer/stevenreimer.com/public_html/index.php(25): Page->show() #4 {main} thrown in /home/sgreimer/stevenreimer.com/includes/classes/TagCloud.class.php on line 188