Skip to content

Instantly share code, notes, and snippets.

@uliwitness
uliwitness / gist:8043486
Last active December 31, 2015 20:59
Looks like the 10.9 SDK breaks code like the following. Anyone know how I can fix that w/o moving the function out of the class? Works fine with the 10.8 SDK.
namespace Carlson
{
class CToken
{
public:
static void GoNextToken( const char* fname, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens );
};
}
@uliwitness
uliwitness / gist:5330743
Last active December 15, 2015 22:09
Macro-based implementation of objects as constants for Objective C. Could probably write code that auto-generates all the OCONSTANTI(a) macro calls based on the OCONSTANT(a) macros. But that wouldn't work for system headers.
#import <Foundation/Foundation.h>
#define PASTE(a,b) a ## b
#define OCONSTANT(a) @class a; extern a* PASTE(k,a); @interface a : NSObject @end
#define OCONSTANTI(a) @class a; a* PASTE(k,a) = nil; @implementation a +(void) load { PASTE(k,a) = [[a alloc] init]; } @end
@uliwitness
uliwitness / gist:4045701
Created November 9, 2012 13:38
Sample script that shows the warning for which I want to find the 'foo' to pass to -Werror=foo (same as you'd pass to -Wfoo)
#import <Foundation/Foundation.h>
@interface MyClass : NSObject
@end
@implementation MyClass
@end
@uliwitness
uliwitness / gist:2415382
Created April 18, 2012 17:47
An (untested) macro and category for easily creating new index sets from unchanging content.
@interface NSIndexSet (ULIIndexSetCreation)
+(NSIndexSet*) indexSetWithIndexes: (const NSInteger [])indexes count: (NSUInteger)count;
@end
@implementation NSIndexSet (ULIIndexSetCreation)
+(NSIndexSet*) indexSetWithIndexes: (const NSInteger [])indexes count: (NSUInteger)count
@uliwitness
uliwitness / gist:2343351
Created April 9, 2012 13:21
Shell script to extract a folder from a git repository to make a new repository with only the history for that folder.
# param 1 is path to root of repository to clone
# param 2 is folder to clone to. The folder's name must be the
# same as the folder to be extracted from the repository at param 1.
GIT='/Applications/Xcode.app/Contents/Developer/usr/bin/git'
$GIT clone --no-hardlinks "$1" "$2"
cd "$2"
$GIT filter-branch --subdirectory-filter "`basename $2`" HEAD #-- --all