Skip to content

Instantly share code, notes, and snippets.

View ccgus's full-sized avatar

August "Gus" Mueller ccgus

View GitHub Profile
$ codesign -vd Acorn.app
Executable=/Users/gus/Downloads/Archives/Acorn.app/Contents/MacOS/Acorn
Identifier=com.flyingmeat.Acorn4
Format=bundle with Mach-O thin (x86_64)
CodeDirectory v=20200 size=43565 flags=0x0(none) hashes=2171+3 location=embedded
Signature size=8518
Timestamp=Jul 14, 2014, 12:47:45 PM
Info.plist entries=35
TeamIdentifier=WZCN9HJ4VP
Sealed Resources version=2 rules=12 files=452
@ccgus
ccgus / gist:7b04e62357a3d36f5ec7
Created August 5, 2014 23:00
Apple sample code
for (CIFaceFeature *f in features)
{
NSLog(NSStringFromRect(f.bounds));
// Should be NSLog(@"%@", NSStringFromRect(f.bounds)); for security reasons
if (f.hasLeftEyePosition)
NSLog("Left eye %g %g", f.leftEyePosition.x. f.leftEyePosition.y);
// Missing @ before opening quote
// Should be f.leftEyePosition.x,
@ccgus
ccgus / gist:8327134
Created January 9, 2014 00:07
NSString isEqual: problems
static Boolean MOObjectEqual(const id value1, const id value2) {
debug(@"(id)value1: '%@'", NSStringFromClass([(id)value1 class]));
debug(@"(id)value2: '%@'", NSStringFromClass([(id)value2 class]));
debug(@"[(id)value1 isKindOfClass:[NSString class]]: %d", [(id)value1 isKindOfClass:[NSString class]]);
debug(@"[(id)value2 isKindOfClass:[NSString class]]: %d", [(id)value2 isKindOfClass:[NSString class]]);
return (Boolean)[(id)value1 isEqual:(id)value2];
}
var list = """George Washington
John Adams
Thomas Jefferson
James Madison
James Monroe
John Quincy Adams
Andrew Jackson
Martin Van Buren
William Henry Harrison
John Tyler
SInt32 TSSystemVersion(void) {
static dispatch_once_t once;
static int TSSystemVersionVal = 0x00;
dispatch_once(&once, ^{
NSDictionary *d = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
NSString *prodVersion = [d objectForKey:@"ProductVersion"];
@ccgus
ccgus / gist:6324222
Created August 23, 2013 21:28
Custom SQLite Functions
[db makeFunctionNamed:@"UTTypeConformsTo" maximumArguments:2 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **argv) {
if (sqlite3_value_type(argv[0]) == SQLITE_TEXT) {
const unsigned char *a = sqlite3_value_text(argv[0]);
const unsigned char *b = sqlite3_value_text(argv[1]);
CFStringRef as = CFStringCreateWithCString(nil, (const char*)a, kCFStringEncodingUTF8);
CFStringRef bs = CFStringCreateWithCString(nil, (const char*)b, kCFStringEncodingUTF8);
sqlite3_result_int(context, UTTypeConformsTo(as, bs));
@ccgus
ccgus / Xcode crash report
Created February 23, 2013 19:02
Xcode crash report whoa
Application Specific Information:
ProductBuildVersion: 4H127
ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilder/IDEInterfaceBuilder-3084/Framework/Connections/Interface/IBConnectionPopUpMenu.m:388
Details: Need a menu.
Function: NSMenuItem *IBPopUpConnectionMenuWithMenuItems(NSArray *, NSMenuItem *, NSEvent *, NSRect, BOOL, NSSet *, CGFloat, NSWindow *, NSColor *, NSColor *, NSColor *, NSColor *, id<IBConnectionPopUpMenuDelegate>)
Thread: <NSThread: 0x40030a1e0>{name = (null), num = 1}
Hints: None
Backtrace:
0 0x000000010c77b249 -[IDEAssertionHandler handleFailureInFunction:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
1 0x000000010ba2ec65 _DVTAssertionHandler (in DVTFoundation)
@ccgus
ccgus / gist:4961749
Created February 15, 2013 17:03
replacing NSImage reps
NSImage *iRep = [NSImage imageNamed:[fileName stringByDeletingPathExtension]];
if (iRep) {
NSImage *ni = [[NSImage alloc] initByReferencingFile:output];
for (NSImageRep *r in [[iRep representations] copy]) {
[iRep removeRepresentation:r];
}
@ccgus
ccgus / gist:4544658
Created January 16, 2013 04:31
FMSimpleBlockAnimation
#import <Cocoa/Cocoa.h>
@interface FMSimpleBlockAnimation : NSAnimation {
void (^_animationBlock)(float t);
}
- (void)animateWithBlock:(void(^)(float t))block;
@end
@ccgus
ccgus / gist:3805275
Created September 29, 2012 21:55
webExportWillWriteHTMLForItem
in your VPWebExportScript page, you can have this which will do simple replacements:
function webExportWillWriteHTMLForItem(contextDictionary, item, fileName, mutableHTMLString) {
mutableHTMLString.replaceOccurrencesOfString_withString_options_range_("<p>", "<div>", 0, NSMakeRange(0, mutableHTMLString.length()));
mutableHTMLString.replaceOccurrencesOfString_withString_options_range_("</p>", "</div>", 0, NSMakeRange(0, mutableHTMLString.length()));
return mutableHTMLString;