Skip to content

Instantly share code, notes, and snippets.

View zwaldowski's full-sized avatar

Zachary Waldowski zwaldowski

View GitHub Profile
switch newValue {
// snip
case .Some(let number as NSNumber):
switch number {
case _ where CFNumberIsFloatType(number) != 0:
self = .JSONDouble(number.doubleValue)
case _ where CFNumberGetType(number) == .CharType || CFGetTypeID(number) == CFBooleanGetTypeID():
self = .JSONBool(number.boolValue)
default:
self = .JSONInt(number.integerValue)
@import Foundation;
NS_ASSUME_NONNULL_BEGIN
@interface MyOneClass : NSObject @end
@implementation MyOneClass; @end
@interface MyOtherClass : MyOneClass @end
@implementation MyOtherClass; @end
@zwaldowski
zwaldowski / TextRanges.swift
Last active January 28, 2017 09:50
Proper bridging for NSRegularExpression; Swift 1.2
import Foundation
// MARK: String
extension String {
func convert(#index: Int) -> Index? {
let utfIndex = advance(utf16.startIndex, index, utf16.endIndex)
return utfIndex.samePositionIn(self)
}
defaults write com.apple.dt.Xcode IDEFileTemplateChooserAssistantSelectedTemplateCategory "Source"
defaults write com.apple.dt.Xcode IDEFileTemplateChooserAssistantSelectedTemplateName "Cocoa Touch Class"
defaults write com.apple.dt.Xcode IDEFileTemplateChooserAssistantSelectedTemplateSection "com.apple.platform.iphoneos"
Swift reStructured text:
Indentation (four space tabs)
Bold ("**bold**")
Italic ("*italics*")
Literals (``double back-quotes``)
Parameters (:param:)
Return types (:returns:)
Definition lists (basically lists with indentation)
@zwaldowski
zwaldowski / GPS-thing.m
Last active March 22, 2018 02:39
GPS video fixer-upper
@import Cocoa;
@import AVFoundation;
@interface AppDelegate : NSObject <NSApplicationDelegate>
@end
static NSArray * metadataFromAssetDictionary(NSArray *sourceMetadata, NSDictionary *metadataDict)
{
NSMutableDictionary *mutableMetadataDict = [NSMutableDictionary dictionaryWithDictionary:metadataDict];
NSMutableArray *newMetadata = [NSMutableArray array];
@import Cocoa;
@interface NSViewController (AuxiliaryWindow)
- (void)zw_presentViewControllerAsAuxiliaryWindow:(NSViewController *)viewController;
@end
@zwaldowski
zwaldowski / notes-specific-to-mac-os-x-10_9.md
Last active April 22, 2025 21:51
10.9 AppKit Release Notes
@zwaldowski
zwaldowski / gist:4b135427d18ac458d2ef
Created January 26, 2015 03:56
Gmail → FastMail
#!/bin/sh
# I first mitigated dupes by only having one label per message in Gmail.
# `imapsync` is https://github.com/imapsync/imapsync
imapsync —host1 imap.gmail.com —user1 <#Gmail address#> —password1 <#Gmail app password#> —ssl1 —port1 993 —host2 mail.messagingengine.com —user2 <#FastMail email#> —password2 <#FastMail one-time password#> —ssl2 —port2 993 —syncinternaldates —noauthmd5 —split1 100 —split2 100 —exclude ‘^\[Gmail\](?!/)’ —exclude All Mail —exclude Spam —exclude Trash —allowsizemismatch
import Foundation
public protocol ErrorRepresentable {
class var domain: String { get }
}
public protocol ErrorCodeRepresentable: ErrorRepresentable, RawRepresentable { }
public protocol LocalizedErrorRepresentable: ErrorRepresentable {
typealias ErrorCode: SignedIntegerType