Skip to content

Instantly share code, notes, and snippets.

Troy Gaul tgaul

View GitHub Profile
View crafting-modern-cocoa-apps-fix-for-xcode8.1-patch.diff
From 94e6ad1869622652b9752e410f3dc24a02bca0f0 Mon Sep 17 00:00:00 2001
From: Troy Gaul <tgaul@mac.com>
Date: Wed, 26 Oct 2016 16:37:43 -0500
Subject: [PATCH] Changes to get compiling with Xcode 8.1.
---
Photo Editor/CanvasViewController.swift | 2 +-
Photo Editor/PhotoController.swift | 2 +-
Photo Editor/PhotoDocumentWindowController.swift | 4 ++--
Photo Editor/SidebarViewController.swift | 8 ++++----
View ATPLogoView.swift
// Source for the Accidental Tech Podcast (ATP) T-Shirt:
// http://www.marco.org/2014/04/29/atp-shirts
//
// By Troy Gaul, June 2, 2014.
//
// Based on Obj-C veresion by Marco Arment, April 28, 2014. MIT license.
// https://gist.github.com/marcoarment/2542cd28cb5df0aa97d8
import UIKit
View gist:9156499
/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.
View CoreDataLessVerbose.m
NSFetchRequest* fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Widget"];
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"type == %@", someType];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"createddate" ascending:YES]];
fetchRequest.fetchLimit = 5;
NSError* error;
NSArray* widgets = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
View InfDebugLog.h
#ifndef NDEBUG
#define InfDebugLog( ... ) NSLog( __VA_ARGS__ )
#else
#define InfDebugLog( ... )
#endif
@tgaul
tgaul / gist:792829
Created Jan 24, 2011
Generating a 1-bit GIF with ImageIO
View gist:792829
- (void) generate1BitGIF
{
UIImage* image = [ UIImage imageNamed: @"TestImage.png" ];
NSFileManager* fm = [ NSFileManager defaultManager ];
NSURL* destDir = [ fm URLForDirectory: NSDocumentDirectory
inDomain: NSUserDomainMask
appropriateForURL: nil
create: YES
error: nil ];
You can’t perform that action at this time.