The Daydream Blog

Archive for the ‘Sample Code’ Category

Using Git With FogBugz for Local Repositories

Thursday, October 22nd, 2009

Note that this article is intended for developers and may not be of interest to a wider audience

If you, like me, have migrated from using Subversion to Git, you may be missing the ability to link commits with FogBugz cases. I have adapted the Subversion integration post commit hook to work with Git.

It should be noted that integration with repositories hosted on GitHub can be found by clicking on this link, to appropriately enough, GitHub (via a blog post on FogBugz). These instructions are for use with local repositories.

I have simply taken the Subverson integration script, that is available at this link on the FogBugz website and adapted it for use with Git.

To use, follow the instructions below:

  • Install Perl in the unlikely situation that it is not already installed on your system
  • Install wget. On Mac OS X, you can install via MacPorts by simply typing sudo port install wget in a Terminal window.
  • Download post-commit and logBugDataGit.pl by clicking on this link to GitFogBugz.zip
  • Unzip the archive and copy the two scripts to your [Path To Project]/.git/hooks directory and make sure they are both executable
  • Edit logBugDataGit.pl as follows:
    • If you are using the free FogBugz version set $BUGZ_URL_FINAL to https://yourdomain.fogbugz.com and set $IS_TRIAL to 1.
    • If you host your own FogBugz installation, set $BUGZ_SERVER to your domain without http:// and set $IS_TRIAL to 0.

That’s it, there is not step 6!

Differencia: Code Acknowledgements

Sunday, November 18th, 2007

One great thing about being a Mac developer at the moment, is that there is a lot of free-to-use, free-to-distribute software that helps you do common things that Apple’s developer frameworks oddly do not provide. So there is quite a lot of third party code in Differencia. The developers are largely unaware of the use of their work in Differencia, or in many other products. I would like to say a big Thankyou to all of those developers whose work has unwittingly gone into Differencia. As well as nestling credits in the About Box, I would like to thank them again here:

Ken Ferry

KFSplitView

Matt Gemmell

NSColor+ContrastingLabelExtensions

TunesWindow

Chris Hanson

BDAlias

Daniel Jakult, Red Sweater Software

NSTableView+RSAutosaving

Andy Matuschak

AMRollOverButton

Help Toolkit

Andy Matuschak / Tom Harrington

Sparkle+

Sean Patrick O’Brien

iLifeControls

Jordy Rose, Belkadan Software

GenericToolbar

Shiira Project

HMBlkAppKit

Chad Weider

CTGradient

Thanks to all of them and I hope that I can contribute back to the Mac developer community in the same way in the not so distant future.

Suicidal Code Redux

Wednesday, October 24th, 2007

Back in July, Daniel Jakult posted some sample code for some suicidal code that prevents your application from running beyond a fixed period after it was compiled. Ideal for a Beta copies of your software that you don’t want used beyond a certain period, without having to deal with licences. For example the Beta release of Differencia that was released last week.

In the comments for Daniel’s post it was pointed out that the sample code was not internationalised and might cause an issue when run outside of English speaking countries. Of the suggested solutions in the comments, one, I suspect, exhibits the same issue and the other is very complex.

I discussed a potential solution with Michal Bencur (benko23) in the #macsb IRC channel a couple of weeks ago and I’ve posted some sample code to resolve the locale issue below.

The gcc documentation states that __DATE__ is in the format “MMM dd yyyy”, but I have no idea whether gcc will localise this when compiling in non English locales, but if it does, just replace “en_US” with the locale you are using when compiling.

The code is also Tiger only, as it uses a 10_4 behaviour date formatter for proper locale handling.

// Based on original code by Daniel Jakult, based on an idea from Brian Cooke.
#ifdef BETA  // 4 week expiration
#define EXPIREAFTERDAYS 28
#endif

#if EXPIREAFTERDAYS
NSString* compileDateString = [NSString stringWithUTF8String:__DATE__];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]
	autorelease]];
[dateFormatter setDateFormat:@"MMM dd yyyy"];
NSDate *compileDate = [dateFormatter dateFromString:compileDateString];
[dateFormatter release];
NSDate *expireDate = [compileDate addTimeInterval:(60*60*24* EXPIREAFTERDAYS)];

if ([expireDate earlierDate:[NSDate date]] == expireDate)
{
	// Run an alert or whatever

	// Quit!
	[NSApp terminate:self];
}
#endif

 
Site by Line