Skip to content

Instantly share code, notes, and snippets.

View modocache's full-sized avatar

Brian Gesiak modocache

View GitHub Profile
# https://drone.io/github.com/modocache/cargo/admin
go get code.google.com/p/go.tools/cmd/cover
go get github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega
go get ./...
go build
$GOPATH/bin/ginkgo -r --randomizeAllSpecs -cover
package signatures
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/binding"
"github.com/martini-contrib/render"
"labix.org/v2/mgo"
)
type Server *martini.ClassicMartini
@modocache
modocache / gist:da56bff7703682f6311d
Last active August 29, 2015 14:19
-[XCTest(AsynchronousTesting) expectationWithDescription:] Hangs for 70+ Seconds: A Stack Trace
Thread 1
Queue : com.apple.main-thread (serial)
#0 0x000000011062aeda in __mmap ()
#1 0x0000000110628acc in mmap ()
#2 0x0000000121178577 in ___lldb_unnamed_function567$$CoreSymbolication ()
#3 0x00000001211789bf in ___lldb_unnamed_function572$$CoreSymbolication ()
#4 0x00000001211777d2 in ___lldb_unnamed_function544$$CoreSymbolication ()
#5 0x00000001211775a7 in ___lldb_unnamed_function541$$CoreSymbolication ()
#6 0x00000001211767c0 in ___lldb_unnamed_function523$$CoreSymbolication ()
#7 0x0000000121176eae in ___lldb_unnamed_function537$$CoreSymbolication ()

Thoughts on Swift 2 Errors

When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.

So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.

Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?

I'm going to cover three things in this post:

NSMutableArray <NSString *> *arrayOfStrings = [NSMutableArray array];
[arrayOfStrings addObject:@"hello"];
[arrayOfStrings addObject:@1]; // compiler error
[arrayOfStrings addObject:(NSString *)@1]; // OK by compiler
NSString *string = [arrayOfStrings firstObject]; // OK by compiler
NSNumber *number = [arrayOfStrings firstObject]; // compiler error
NSNumber *actuallyANumberThough = (NSNumber *)[arrayOfStrings lastObject]; // OK by compiler, and will work at runtime
@modocache
modocache / gist:82a32312af663ea59782
Created September 27, 2015 17:00
Xcode Stack Trace
Process: Xcode [59837]
Path: /Applications/Xcode-beta.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 7.1 (9069)
Build Info: IDEFrameworks-9069000000000000~10
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [59837]
User ID: 1199935289
@modocache
modocache / Procfile
Created April 13, 2012 16:58
Sample Procfile
web: python manage.py run_gunicorn -b 0.0.0.0:$PORT -w 3
worker: python manage.py celeryd -E -B --loglevel=INFO
@modocache
modocache / gist:2501598
Created April 26, 2012 18:17
CocoaPods <3 RestKit
platform :ios
dependency 'RestKit/Network', '0.9.3'
dependency 'RestKit/ObjectMapping', '0.9.3'
dependency 'RestKit/ObjectMapping/CoreData', '0.9.3'
dependency 'RestKit/ObjectMapping/JSONKit', '0.9.3'
@modocache
modocache / gist:2501599
Created April 26, 2012 18:17
CocoaPods <3 RestKit
platform :ios
dependency 'RestKit/Network', '0.9.3'
dependency 'RestKit/ObjectMapping', '0.9.3'
dependency 'RestKit/ObjectMapping/CoreData', '0.9.3'
dependency 'RestKit/ObjectMapping/JSONKit', '0.9.3'
@modocache
modocache / gist:3021613
Created June 30, 2012 00:44 — forked from rmyers/appengine.sh
Create a Virtual ENV for appengine and python2.5
#!/bin/bash
#
# Build a virtual environment suitable for running appengine.
# This uses virtualenvwrapper to make the virtual environment.
# Which you can activate with 'workon appengine'
#
# Everyone loves one-liners!
# Mac one-liner:
# $ curl -s https://raw.github.com/gist/3021613 | bash
#