Skip to content

Instantly share code, notes, and snippets.

View bazscott's full-sized avatar

Baz Scott bazscott

View GitHub Profile
//
// Copyright © 2015 The CocoaBots. All rights reserved.
import Cocoa
import RealmSwift
enum RealmDocumentError: ErrorType {
case FailedToConvertURLToFilePath
}
@bazscott
bazscott / A Random Thing
Created May 15, 2014 08:49
A Random Thing - Provide an array and pick one of them at random
options = Array["GCD Midtown", "ShopKeep", "Rumble"]
puts "\n\nSelecting from: #{options}"
puts "And the winner is: " + options.at(Random.rand(options.size)) + "\n\n"
@bazscott
bazscott / Logic Interview Questions - good and bad
Created October 8, 2013 14:16
A couple of interview questions that I have been asked
A Bad Logic Question
--------------------
- I was asked this by the Royal Air Force, just after the interviewer threw a bunch of keys at me unexpectedly :)
Question: Assume there is a room with three light bulbs in it. Outside the room is a light switch with 3 switches on it labeled A, B, and C. Once you enter the room, you will no longer be able to access the switches. How can you, upon entering the room, tell me which of the three switches controls each of the light bulbs?
A Good Logic Question
---------------------
@bazscott
bazscott / Code Snippets for Dash
Created September 18, 2013 19:36
A collection of the code snippets I use in Dash
// ====================================================
// SINGLETON
// ====================================================
+ (__class__ *)__accessor__ {
static dispatch_once_t pred;
static __class__ *__singleton__ = nil;
dispatch_once(&pred, ^{
__singleton__ = [[__class__ alloc] init];
});
@bazscott
bazscott / todos_as_warnings_xcode
Created September 4, 2013 10:12
Show TODOs And FIXMEs As Warnings in Xcode
- Select the project in Project Navigator
- Open the Build Phases tab
- Add a new "Run Script" build phase
- Insert the following script:
KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"