Skip to content

Instantly share code, notes, and snippets.

Avatar

James Montgomerie th-in-gs

View GitHub Profile
@th-in-gs
th-in-gs / gist:907479
Created Apr 7, 2011
Scottish Ruby Conference Charity Tutorial
View gist:907479
def counter(start=0, increment=1)
lambda do
ret = start
start += increment
ret
end
end
result = counter(10, 2);
result2 = counter(10, 2);
@th-in-gs
th-in-gs / AppServerSetup.rb
Created Apr 7, 2011
Scottish Ruby Conference Charity Tutorial Exercise #2
View AppServerSetup.rb
class AppServer
attr_accessor :port, :admin_password
end
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
def app_server
if block_given?
if @app_server.nil?
@th-in-gs
th-in-gs / ArvoPrioritisedBlockOperation.h
Created Nov 16, 2012
NSOperation subclass with customisable dispatch_queue_priority
View ArvoPrioritisedBlockOperation.h
//
// ArvoPrioritisedBlockOperation.h
// Arvo
//
// Created by James Montgomerie on 16/11/2012.
// Copyright (c) 2012 Things Made Out Of Other Things. All rights reserved.
//
#import <Foundation/Foundation.h>
@th-in-gs
th-in-gs / gist:4161072
Created Nov 28, 2012
Response to "Surprising ARC performance characteristics" (http://blog.securemacprogramming.com/?p=668)
View gist:4161072
[myDictionary enumerateKeysAndObjectsUsingBlock: ^(id key, id object, BOOL *stop) {
//...
}];
to:
for(id key in myDictionary) {
id object = myDictionary[key];
//...
}
@th-in-gs
th-in-gs / gist:4722001
Last active Dec 12, 2015
LLVM Bug Report Response, "Static analyzer false positive when iterating C array"
View gist:4722001

Hi James,

This is a courtesy email regarding Bug ID# 13107141.

Engineering has provided a workaround that you can use while we continue working on a resolution of the issue:

In this case, the analyzer does not know that both the loop which initializes the values and the loop that uses them will be executed the same number of times. You can hint to the analyzer that that is the case, by adding the following assert before the second loop: assert(numbersIndex == numbersCount);

Alternatively, you could use numbersIndex instead if numbersCount in the second loop.

View Coolson's Beta: A Word on Game Center.md

Coolson's Beta: A Word on Game Center.

Beta apps like Coolson's use a different, separate Game Center to the real one that apps from the App Store use. Apple calls it the "Sandbox" Game Center. You will need to create a Sandbox Game Center account when you first play Coolson's - it will prompt you. The Sandbox Game Center is entirely separate from the real one. You can use the same AppleID as you usually use, and hopefully your usual Game Center nickname will still be available in the Sandbox - if it's not, you'll need to choose another, I'm afraid!

An iPad can only be logged in to either the sandbox or the real Game Center. Launching Coolson's will automatically log you out of Game Center into Sandbox Game Center. Launching an App Store app that uses Game Center will log you out of the Sandbox Game Center and into Game Center. Launching the iPad's preinstalled "Game Center" app will not change which Game Center you're logged into; it will show the Sandbox if you previously played Coolson's, and the

View NSObject+KVOWeakPropertyDebug.h
//
// NSObject+KVOWeakPropertyDebug.h
// KVOWeakPropertyDebug
//
// Created by Vladimir Grichina on 12.01.13.
// Copyright (c) 2013 Vladimir Grichina. All rights reserved.
//
#import <Foundation/Foundation.h>