Skip to content

Instantly share code, notes, and snippets.

View jbrjake's full-sized avatar

Jonathon Rubin jbrjake

View GitHub Profile
@jbrjake
jbrjake / gist:5172336
Created March 15, 2013 19:18
I like GCD syntax better than NSOperations, but currently my app has to support 10.5. And I don't want to have to test two different execution paths for 10.5 and 10.6+. So I'm basing the one to use off the MIN_REQUIRED macro, which per TN2064 will be the same as the DEPLOYMENT_TARGET. My GCD code doesn't execute now, but will whenever I can drop…
if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6) {
// Use NSOperations
}
else {
// Use GCD
}
#!/bin/sh
#
# Copyright (c) 2007 Andy Parkins
#
# An example hook script to mail out commit update information. This hook
# sends emails listing new revisions to the repository introduced by the
# change being reported. The rule is that (for branch updates) each commit
# will appear on one email and one email only.
#
# This hook is stored in the contrib/hooks directory. Your distribution
You have a stream of bytes in char array buf[]:
00 00 00 0A 68 65 6C 6C 6F 77 6F 72 6C 64
You know the bytes follow a protocol with this spec:
<1 byte> message type (0 == hello, 1 == goodbye)
<3 bytes> message length
<N> message content (UTF-8 characters)
Determine if this is a hello message, and, if it is, print the content as a string to stdout.
@jbrjake
jbrjake / gist:9530557
Created March 13, 2014 15:27
Mac developer interview questions
Q: What’s wrong with this code?
NSLock* arrayLock = GetArrayLock();
NSMutableArray* myArray = GetSharedArray();
id anObject;
[arrayLock lock];
anObject = [myArray objectAtIndex:0];
[arrayLock unlock];
Funny Tech Tweets
=================
### Corny ###
I know a programming joke about 10,000 mutexes, but it's a bit contentious.
--@secboffin
I also have a UDP joke. But you might not get it.
--@jonathanstray
@jbrjake
jbrjake / gist:6f36fb64c4ffd19f35db
Last active August 29, 2015 14:02
Cleaner async with Swift
Obj-C async calls
=================
Background queue
----------------
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do stuff
});
I found this whole file randomly looking through a Terry Pratchett ftp directory on, if I recall, an MIT machine, back in 1995 or 96. I luckily saved a copy, as I haven't been able to find it since...
'You know my motto: Forgive and uh... the other thing.'
Bus error: passengers dumped
COBOL programmers understand why women hate periods.
@jbrjake
jbrjake / CoreDeadlock.m
Created August 19, 2015 21:42
The fun of Core Data concurrency
#import "ViewController.h"
#import <CoreData/CoreData.h>
#import "AppDelegate.h"
@interface ViewController ()
@end
@implementation ViewController
@jbrjake
jbrjake / narcis.swift
Last active May 5, 2016 05:05
From laziness, vanity
//: Playground - noun: a place where people can play
import UIKit
protocol AnyEquatable {
func equals(otherObject: AnyEquatable) -> Bool
}
extension AnyEquatable {
func equals(otherObject: AnyEquatable) -> Bool {
return false