This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <libkern/OSAtomic.h> | |
@implementation SomeClass | |
+ (id) someStaticValueComputedOnFirstAccess | |
{ | |
static volatile id __staticVar = nil; | |
if ( __staticVar == nil ) | |
{ | |
id var = [[Something alloc] init]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// BlocksRuntime | |
// | |
// Created by Jim Dovey on 11-07-22. | |
// Copyright 2011 Jim Dovey. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* $TM_FILENAME | |
* ${1:`echo "$TM_FILEPATH" | awk -F"/" '{x=NF-1}{print $x}'`} | |
* | |
* Created by `id -P | awk -F ":" '{ print $8 }'` on `date "+%d/%m/%Y"`. | |
* | |
* Copyright (c) `date +%Y` ${2:$TM_ORGANIZATION_NAME} | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSString * const AQPerThreadManagedObjectContext = @"AQPerThreadManagedObjectContext"; | |
void StoreManagedObjectContextForCurrentThread( NSManagedObjectContext * context ) | |
{ | |
[[[NSThread currentThread] threadDictionary] setObject: context forKey: AQPerThreadManagedObjectContext]; | |
} | |
NSManagedObjectContext * PerThreadManagedObjectContext( void ) | |
{ | |
NSManagedObjectContext * result = [[[NSThread currentThread] threadDictionary] objectForKey: AQPerThreadManagedObjectContext]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@protocol APRemoteAddressBook <NSObject> | |
- (void) allPeople: (void (^)(NSArray *, NSError *)) reply; | |
- (void) mailingAddressesForPersonWithIdentifier: (NSString *) identifier | |
reply: (void (^)(NSArray *, NSError *)) reply; | |
- (void) emailAddressesForPersonWithIdentifier: (NSString *) identifier | |
reply: (void (^)(NSArray *, NSError *)) reply; | |
- (void) phoneNumbersForPersonWithIdentifier: (NSString *) identifier | |
reply: (void (^)(NSArray *, NSError *)) reply; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Thirty minute timeout | |
with timeout of 108000 seconds | |
repeat while true | |
delay 5 | |
set baseurl to "https://developer.apple.com/devcenter/ios/index.action" | |
set curlshellcode to "curl " & baseurl | |
set theshellresult to do shell script curlshellcode | |
if theshellresult does not contain "maintenance" then | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
State of my main queue while running a block (at the start of main() before it all goes pear-shaped) | |
(lldb) expr (void) dispatch_debug((void *)dispatch_get_current_queue(), "main q") | |
=== log file opened for Kobo[7195] at 1337357109.056275 === | |
com.apple.main-thread[0xad009600] = { xrefcnt = 0xffffffff, refcnt = 0xffffffff, suspend_cnt = 0x0, locked = 1, target = com.apple.root.default-overcommit-priority[0xad009b00], width = 0x0, running = 0x0, barrier = 1 }: main q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface AQNonZeroBasedArray : NSArray | |
@end | |
@implementation AQNonZeroBasedArray | |
{ | |
NSArray * _realArray; | |
NSUInteger _base; | |
} | |
// initialize it using AQNonZeroBasedArray * array = @[obj1, obj2, obj3]; |
NewerOlder