We've recently switched our blog from a self-hosted Word Press installation to Pyblosxom. Word Press was a little too over-engineered for our needs and it was also complicated to customise themes.
In comparison Pyblosxom (a port of the original Perl based Blosxom blogging engine) is simiplicity itself. All posts are simple text files. We are using the Markdown plugin which makes writing posts even easier. Creating a new post is simply a matter of uploading a text file to our sever.
Pyblosxom's appearance can be customised by creating "flavours". At their simplest a flavour consists of three (html formatted) files "head", "story" and "foot". Provide some CSS and you're done.
The final piece of the puzzle for us was source code syntax highlighting. We settled on highlight.js, again because of its simplicity (a single Javascript file) and nice range of built-in styles. The highlighter will automatically style all <code> blocks, including auto-detection of the language.
Our blog is currently small, but if it ever gets too big or popular Pyblosxom has a static rendering option to fall back on. So finger's crossed we should be future proof and without the overhead or maintanence problems of a self-hosted Word Press installation.
Posted by: /john
The Core Data Programming Guide “Multi-Threading with Core Data” notes the following:
Performing a save operation in a detached thread is error-prone unless you take additional steps to prevent the application from quitting before the save is completed. Specifically, all NSThread-based threads are “detached” (see the documentation for pthread for complete details) and a process runs only until all not-detached threads have exited. The work a detached thread is performing is therefore considered optional, and the process may terminate at any time. (Most users do not consider saving to be optional work!) In Cocoa, only the main thread is not-detached. If you need to save on other threads, you must write additional code such that the main thread prevents the application from quitting until all the save operation is complete.
No clues as to how to write said additional code, though!
In case it’s useful to anyone, here’s how I’ve done it. Simply change your app’s delegate to be a subclass of OTApplicationDelegate instead of UIApplicationDelegate, and sandwich critical sections of your background threads with code similar to the NSManagedObjectContext category presented.
This work is licensed under a Creative Commons Attribution 2.5 UK: Scotland License.
NSManagedObject+OTAdditions.m:
@implementation NSManagedObjectContext (OTAdditions)
- (void)saveOrDie
{
OTApplicationDelegate *sharedDelegate = [[UIApplication sharedApplication] delegate];
if ([sharedDelegate temporarilyPreventQuit])
{
NSError *saveError = nil;
NSAssert([self save:&saveError], [saveError description]);
[sharedDelegate cancelPreventQuit];
}
else
NSLog(@"Warning: did not save %@ due to pending quit", self);
}
@end
OTApplicationDelegate.h:
@interface OTApplicationDelegate : NSObject
{
BOOL myQuitting;
NSCondition *myCondition;
NSInteger myPreventorCount;
}
@property (nonatomic, readonly) BOOL quitting;
- (BOOL)temporarilyPreventQuit;
- (void)cancelPreventQuit;
@end
OTApplicationDelegate.m:
@implementation OTApplicationDelegate
- (void)dealloc
{
[myCondition release], myCondition = nil;
[super dealloc];
}
- (id)init
{
self = [super init];
if (self)
myCondition = [[NSCondition alloc] init];
return self;
}
- (BOOL)quitting
{
return myQuitting;
}
- (BOOL)temporarilyPreventQuit
{
if ([NSThread isMainThread])
return YES;
[myCondition lock];
if (myQuitting)
++myPreventorCount;
[myCondition unlock];
return !myQuitting;
}
- (void)cancelPreventQuit
{
if ([NSThread isMainThread])
return;
[myCondition lock];
if (--myPreventorCount < 1)
[myCondition signal];
[myCondition unlock];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"waiting for detached threads...");
[myCondition lock];
myQuitting = YES;
while (myPreventorCount > 0)
[myCondition wait];
[myCondition unlock];
NSLog(@"...detached threads finished");
}
@end
Posted by: /hamish
I’ve just updated our screen saver, Collage Saver, for Snow Leopard. After poking around a little I discovered (via the Apple dev forums) that you need to make the following changes to load screen saver bundles in 64-bit Snow Leopard:
So for in Collage Saver’s project file I made the following changes:
That’s it. Your screen saver will now load on 10.6 and 10.5 (Intel or PowerPC).
You can download the latest version of Collage Saver here.
Posted by: /john
Here is an example of using a CATiledLayer to present a large, zoomable PDF in a UIScrollView.
http://olivetoast.com/blog/code/SimpleTiledScrollExample.zip
It’s about 50 lines of code in addition to what’s provided by the view-based app template.
If you’re wondering why UIScrollView zooming is designed the way it is, CATiledLayer might be the explanation you’re looking for.
Hope it proves useful to somebody!
Posted by: /hamish