lyonkingdom.com
Greg

SVN best practice #1: Check status before updating!

I maintain several websites as Subversion Checkouts.  I’ve had great luck with this as long as everyone on my team follows a few rules, and I thought I’d start saving & sharing some of them here.  This brief article explains the use of a couple of key SVN commands.

One of the things I’ve gotten in the habit of lately is to check the version of each and every file that I’m about to update whenever I do a big server update like we did last night for a busy website.  In this case it was VERY helpful to have done-so because I accidentally released a new beta version of  a few files that our client hadn’t approved yet.  Since I have the ‘list’ of all files that I’ve changed it’s quite easy to revert a few if necessary.  It works very well.

In brief, here’s what you do:
Before any update, check the status of all files with this svn command:
svn status -u
The status command with the -u option tells SVN to go compare everything locally to what’s in the repository.  You get output like this:
    *   3362   new_feature/feature.msi
    *   3362   new_feature/feature.exe

Any file with a * will be updated if you perform an SVN update, but it also tells you what version you’re currently on.  Then I updated my website to v3450 (including the not-ready-for-prime-time files).  Once I realized my error it was a simple matter to do an svn update to a revision as follows:

svn up -r3362

I performed this update right inside the ‘not-ready-for-prime-time’ folder and it caused these files to update back to the revision closest to 3362.  BAM!  Done and Done.  Note that this update-to-revision is not sticky, so I’ll have to be careful if I update the server again before these particular files are approved.  Also, note that I’ve ignored another best-practice here which is that I should have had my developer put this beta area on a branch, which would have avoided this issue all-together; but that is a topic for another post.

SVN Status can also tell you other important information, here are a couple cases:
?             feature.back
The ? lets you know that this file hasn’t ever been checked in to SVN.
M   *  3362   help.php
this file has been Modified (M) locally without being checked in AND is modified (*) in SVN.  Watch out for potential conflicts!

I really, really don’t like to have me or my programmers editing files right on the production server except in dire circumstances, so I usually go have a talk with someone about it whenever I find these types of entries.  I also make sure to clean them up right away once I notice them.

Anyway, I hope you found this helpful.


Posted by Greg on October 17th, 2011 :: Filed under Subversion,Tips

MS Excel: a formula for Ordinal Numbers

Today I was surprised to find that Microsoft Excel 2010 still doesn’t have a format option for Ordinal Numbers; dates or numbers such as 1st, 2nd, 3rd, 4th (etc).  I wanted to display dates like this: Sat, Jun 4th. A quick search revealed some functions that people had written, but I wanted to do it in-cell so I whipped up the following formula…

=TEXT(A2,"ddd, mmm d")  &
IF(OR(DAY(A2)=1,DAY(A2)=21,DAY(A2)=31),"st",
IF(OR(DAY(A2)=2,DAY(A2)=22),"nd",
IF(OR(DAY(A2)=3,DAY(A2)=23),"rd","th")))

It seemed like it should have been easier until I realized that 11,12,13 are th’s. The first line of this formula does nearly all of the work…the TEXT function can give Sat, Jun 4. The three lines of IF() are just to display st, nd, rd, or th. This function only works for calendar dates, after 31 it falls apart.

You may find it easier to read if you use carriage returns in lengthy formulas.  Simply press ALT+ENTER while editing in a cell.  Also you can drag the formula box taller to ease the process. For more details on Excel’s TEXT function, look here http://office.microsoft.com/en-us/excel-help/text-function-HP010062580.aspx to see the formatting options and examples.  Expand the headers in the syntax section to see details about numbers, dates and times, currency, strings, etc. that TEXT display.

Let me know if you’ve found another way to do this.

Hey here are some, and they’re not limited to calendar days: http://www.cpearson.com/excel/ordinal.htm


Posted by Greg on June 5th, 2011 :: Filed under MS Excel,Tips