Skip to content

Instantly share code, notes, and snippets.

View wjlafrance's full-sized avatar
🐶
Wondering if Github is becoming a social network.

William LaFrance wjlafrance

🐶
Wondering if Github is becoming a social network.
View GitHub Profile
@wjlafrance
wjlafrance / MyPlayground.swift
Last active August 29, 2015 14:18
Result<T,U> working in Xcode 6.3
//: Playground - noun: a place where people can play
import Darwin
class Box<T> {
let contents: T
init(_ contents: T) { self.contents = contents }
}
@wjlafrance
wjlafrance / ThisIsNotTheErrorYouAreLookingFor.swift
Created May 28, 2015 19:49
ThisIsNotTheErrorYouAreLookingFor.swift
// This is an object we want to JSON encode. We need to know if it's a dictionary or array.
let instance: AnyObject = [1, 2, 3] as! AnyObject
// Checking if an object is a non-parameterized generic type is not supported
if instance is Array { // Argument for generic parameter 'T' could not be inferred
println("It's an array")
}
// When combing the two `is` checks, each independently invalid, the compiler shows the wrong errror.
@wjlafrance
wjlafrance / MethodsOfHandlingNil.swift
Last active September 14, 2015 20:48
MethodsOfHandlingNil.swift
/**
* The contract of this method is that the method will check if unsafeThing is nil before using it.
* This contract is not encoded in the method signature and is not compiler-enforced!
*/
func safelyHandlesIUO(unsafeThing: String!) {
println("This isn't an optional. We can use it directly but may find nil and crash: \(unsafeThing)")
if let safeThing = unsafeThing {
println("String is \(count(safeThing)) length")
} else {
println("Woah, we would have crashed if we passed it to count!")
#!/bin/sh
#ID='A16FF353-8441-459E-A50C-B071F53F51B7' # Xcode 6.2
#ID='992275C1-432A-4CF7-B659-D84ED6D42D3F' # Xcode 6.3
ID='7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90' #Xcode 6.4
#ID='AABB7188-E14E-4433-AD3B-5CD791EAD9A3' # Xcode 7.0
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
@wjlafrance
wjlafrance / main.m
Last active January 26, 2016 21:16
xeye - combine side-by-side 3d into red/blue glasses format
// Written March 26th 2013
#import <Cocoa/Cocoa.h>
#import <AVFoundation/AVFoundation.h>
int main(int argc, char **argv) {
NSLog(@"Hello world");
NSError *err;
Hi Will,
Thanks for considering [redacted]! We appreciate you taking the time to
talk to us.
We received a lot of interest in our iOS position, and after reviewing the
resources you sent, we're certain that your application is not one we'll be
considering for the position.
We love your commitment to open source, and we encourage you to continue to
@wjlafrance
wjlafrance / keybase.md
Created February 11, 2016 19:31
Keybase Verification

Keybase proof

I hereby claim:

  • I am wjlafrance on github.
  • I am wjlafrance (https://keybase.io/wjlafrance) on keybase.
  • I have a public key ASAGoL5HJfvOtSQMFfzEVHnSM6rvW3z_gckZSdxdox742Qo

To claim this, I am signing this object:

@wjlafrance
wjlafrance / gist:68eec1ae85836b4240cf
Last active February 15, 2016 06:21
Ubuntu 15.10 Swift
Create machine in VMware Workstation. Typical installation, 60GB disk, Ubuntu 15.10 Desktop x64 ISO.
Shut down machine, increase to 2 Processors / 1 Core Each, increase to 8GB RAM.
$ sudo apt-get update; sudo apt-get dist-upgrade
$ sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config
$ sudo apt-get install gnome-flashback-session
Log out, change to Gnome Metacity session, log back in
@wjlafrance
wjlafrance / wat.swift
Created March 5, 2016 06:10
I don't know how to dateformatter
Expect: 2016-02-08 15:43:32 +0000
Got: 2016-02-08 18:43:32 +0000
2016-02-08 12:43:32 +0000
Barebones PC:
Lenovo TS140
http://www.amazon.com/gp/product/B00F6EK9J2
$219.99 (2015-01-12)
Processor:
Intel Xeon E3-1231
http://www.amazon.com/gp/product/B00KB4A2XA
$254.99 (2016-02-25)