Skip to content

Instantly share code, notes, and snippets.

View AlanQuatermain's full-sized avatar

Jim Dovey AlanQuatermain

View GitHub Profile
@AlanQuatermain
AlanQuatermain / gist:98622
Created April 20, 2009 17:08
Xcode License Header Script
#!/usr/bin/ruby
require 'osx/cocoa'
require 'date'
OSX.require_framework "AddressBook"
filePath = "%%%{PBXFilePath}%%%"
fileName = File.basename(filePath)
projName = File.basename(File.dirname(filePath))
@AlanQuatermain
AlanQuatermain / gist:100277
Created April 23, 2009 03:24
How to make a UIWebView in a table cell fill the ugly grey bit with rendered data
@interface UIWebView (WebViewManualRedrawSupport)
- (id) _documentView;
@end
@interface NSObject (WebViewManualRedrawSupport)
- (id) _webCoreNeedsDisplay;
@end
@implementation MyTableCellContainingAWebView (GetRidOfUglyGreyBlock)
@AlanQuatermain
AlanQuatermain / symbolicatecrash.pl
Last active August 30, 2015 07:34
Fixed version of symbolicatecrash for iPhone OS 3.0 devices.
#!/usr/bin/perl
#
# This script parses a crashdump file and attempts to resolve addresses into function names.
#
# It finds symbol-rich binaries by:
# a) searching in Spotlight to find .dSYM files by UUID, then finding the executable from there.
# That finds the symbols for binaries that a developer has built with "DWARF with dSYM File".
# b) searching in various SDK directories.
#
# Copyright (c) 2008 Apple Inc. All Rights Reserved.
@AlanQuatermain
AlanQuatermain / Memory.c
Created May 15, 2009 16:05
Utilities for getting memory allocation & free amounts (works on Mac & iPhone).
/*
* Memory.c
* Outpost
*
* Created by Jim Dovey on 23/04/09.
* Copyright 2009 Morfunk, LLC. All rights reserved.
*
* Copyright (c) 2009, Jim Dovey
* All rights reserved.
*
@AlanQuatermain
AlanQuatermain / gist:119712
Created May 29, 2009 01:19
A lockless way of setting a lazily-initialized static global value. It works by using a CompareAndSwap atomic operation with a memory barrier to sync threads' instruction & data caches. If another thread sets the value since we looked at __staticVar, Comp
#import <libkern/OSAtomic.h>
@implementation SomeClass
+ (id) someStaticValueComputedOnFirstAccess
{
static volatile id __staticVar = nil;
if ( __staticVar == nil )
{
id var = [[Something alloc] init];
@AlanQuatermain
AlanQuatermain / gist:185377
Created September 11, 2009 15:54
Example of modifying synchronous code to asynchronous with GCD.
// Before:
- (IBAction) optimizeDataObject: (MyDataObject *) obj
{
// going to start work, so show the user that something's happening
[self.progressIndicator startAnimating];
// these two are *usually* quick -- unless the user opens a 1GB file.
// because this is happening in an event handler, it'll stall the event loop, which
// causes the good ol' spinning beachball of death
[self pruneDuplicatesInDataObject: obj];
- (void) functionWhichAnnoyinglyBlocksExecution: (NSFileHandle *) annoyingFileHandle
{
dispatch_async(dispatch_get_global_queue(0,0), ^{
id result = [annoyingFileHandle someBlockingOp];
dispatch_async(dispatch_get_main_queue(), ^{
[myController displayResult: result];
});
});
}
@AlanQuatermain
AlanQuatermain / insert-bsd-header-snippet
Last active September 1, 2020 21:48
A TextMate snippet to create a BSD License header for your source file.
/*
* $TM_FILENAME
* ${1:`echo "$TM_FILEPATH" | awk -F"/" '{x=NF-1}{print $x}'`}
*
* Created by `id -P | awk -F ":" '{ print $8 }'` on `date "+%d/%m/%Y"`.
*
* Copyright (c) `date +%Y` ${2:$TM_ORGANIZATION_NAME}
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/*
* proplist.go
* PropertyLists
*
* Created by Jim Dovey on 17/11/2009.
*
* Copyright (c) 2009 Jim Dovey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@AlanQuatermain
AlanQuatermain / smart_status.c
Created December 7, 2009 01:49
A simple C program to display SMART status for all supported disks.
/*
* smart_status.c
* SMARTStatus
*
* Created by Jim Dovey on 6/12/2009.
*
* Copyright (c) 2009 Jim Dovey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without