Scott's Notes

Feb 18

Extract Address Book Address Values on iPhone OS

Feb 12

Comparing Dates in Objective-C

NSDate * dateOne = [NSDate date];
NSDate * dateTwo = [NSDate date];

if([dateOne compare:dateTwo] == NSOrderedAscending) {
    // dateOne is before dateTwo
}

(Source: myuiviews.com)

iOS Polygon Hit Test with CGMutablePathRef, CGPoint, and CGPathContainsPoint -

- (BOOL) containsPoint: (CGPoint) aPoint
{
	// Prepare corner of isometric map (rhombus).
	CGPoint points[4];
	points[3] = ccp(0.5f * self.tmxMap.contentSize.width, 0);
	points[2] = ccp(self.tmxMap.contentSize.width, 0.5f  * self.tmxMap.contentSize.height);
	points[1] = ccp(0.5f * self.tmxMap.contentSize.width, self.tmxMap.contentSize.height);
	points[0] = ccp(0, 0.5f * self.tmxMap.contentSize.height);

	// Use CGPath methods to determine if rhombus contains a point.
	CGMutablePathRef path=CGPathCreateMutable();
	CGPathMoveToPoint(path, NULL, points[0].x, points[0].y);
	CGPathAddLineToPoint(path, NULL, points[1].x, points[1].y);
	CGPathAddLineToPoint(path, NULL, points[2].x, points[2].y);
	CGPathAddLineToPoint(path, NULL, points[3].x, points[3].y);
	CGPathCloseSubpath(path);
	return CGPathContainsPoint(path, NULL, aPoint, YES);
}

Oct 04

The Stack Exchange Architecture – 2011 Edition, Episode 1

Oct 03

Markdown in JavaScript

Text Editors for Programmers on the Mac -

I’ve mostly been using Kod but I might give Sublime Text a try.

Apr 29

ASP.NET MVC Authorize Attribute with Access Denied Page -

I struggled to get the ASP.NET MVC Authorize attribute to redirect to an “Access Denied” page when the user was not in the specified role. I was using windows authentication and no matter what I set in the web config customErrors section (which was recommended) the user would always be prompted to enter a username and password instead. I found this stack overflow answer that suggests using a custom attribute. It’s the only thing I’ve found that works.

Apr 28

Windsor Logging Facility for log4net -

Can’t wait to try it out. No more coding static logger instances!

Apr 27

NHibernate 3.2: Better Batching Support for Cascades -

NHibernate now supports batch sets when performing cascade operations.

Apr 26

Using Query Classes With NHibernate -

While query objects may not always be advisable, Liam has an interesting approach using a base class and an extension method for ISession.