Skip to content

Instantly share code, notes, and snippets.

View zwaldowski's full-sized avatar

Zachary Waldowski zwaldowski

View GitHub Profile
//
// ZWMacros.h
// Aieeeee
//
// Created by Zach Waldowski on 3/26/14.
// Copyright (c) 2014 Big Nerd Ranch. All rights reserved.
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
NSMapTable *table = [NSMapTable strongToWeakObjectsMapTable];
[table setObject:@"foo" forKey:@protocol(NSCopying)];
[table setObject:@"bar" forKey:[NSString class]];
NSLog(@"%@", table);
}
}
@zwaldowski
zwaldowski / keybase.md
Created June 16, 2014 18:00
Keybase verification

Keybase proof

I hereby claim:

  • I am zwaldowski on github.
  • I am zwaldowski (https://keybase.io/zwaldowski) on keybase.
  • I have a public key whose fingerprint is 04DB 3D6C 138B 5630 57E2 B5A4 01F1 4578 8F2E 8CD3

To claim this, I am signing this object:

import Swift
@assignment func -=<T, U where T: ArrayType, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element>(inout lhs: T, rhs: U) {
for removingItem in rhs {
for (index, item) in enumerate(lhs) {
if removingItem == item {
lhs.removeAtIndex(index)
}
}
}
@zwaldowski
zwaldowski / gist:ac07e990dacfa0880302
Created August 4, 2014 18:04
Honk honk, DP train
$ sudo defaults write /var/db/SUPrefOverrides.plist CatalogURL -string https://swscan.apple.com/content/catalogs/others/index-10.10seed-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz
$ sudo chmod 0644 /var/db/SUPrefOverrides.plist
import Cocoa
let data: NSData = `...`
var jsonError: NSError?
let decodedJson = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &jsonError) as NSDictionary!
if decodedJson != nil {
println(decodedJson["title"])
}
@import QuartzCore.CABase;
#import <Kiwi/Kiwi.h>
#ifndef CGFLOAT_EPSILON
#if CGFLOAT_IS_DOUBLE
#define CGFLOAT_EPSILON DBL_EPSILON
#else
#define CGFLOAT_EPSILON FLT_EPSILON
#endif
#endif
class MyClass {
lazy var property: String! = {
println("Inside the initializer!")
return "Fallback"
}()
}
let obj = MyClass()
_homebrew-installed() {
type brew &> /dev/null
}
_rbenv-from-homebrew-installed() {
brew --prefix rbenv &> /dev/null
}
FOUND_SDK=0
androidsdkdirs=("/opt/android-sdk" "/usr/local/opt/android-sdk" "$HOME/Applications/Android Studio.app/sdk" "/Applications/Android Studio.app/sdk" )
@zwaldowski
zwaldowski / UIFontDescriptor+DynamicType.m
Created November 9, 2014 22:06
Dynamic Type with Weight-Matching
@implementation UIFontDescriptor (DZWDynamicType)
+ (instancetype)dzw_preferredFontDescriptorWithTextStyle:(NSString *)style {
return [[self preferredFontDescriptorWithTextStyle:style] dzw_fontDescriptorWithMatchingFamily:@"Avenir Next"];
}
- (instancetype)dzw_fontDescriptorWithMatchingFamily:(NSString *)family {
NSMutableDictionary *attributes = [self.fontAttributes mutableCopy];
[attributes removeObjectForKey:UIFontDescriptorTextStyleAttribute];
UIFontDescriptor *newDesc = (__bridge_transfer UIFontDescriptor *)CTFontDescriptorCreateCopyWithFamily((__bridge CTFontDescriptorRef)self, (__bridge CFStringRef)family);