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
#define S(_s) @selector(application##_s:) // selector generator | |
#define N(_n) UIApplication##_n##Notification // name generator | |
#define L(X) X(WillResignActive), X(DidEnterBackground), \ | |
X(WillEnterForeground), X(DidBecomeActive), X(WillTerminate) // apply X over list | |
#define C(_a) sizeof((_a))/sizeof((_a)[0]) // array count | |
- (void)monitorAppState:(BOOL)start | |
{ | |
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
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
# | |
# Ruby Script to convert FontAwesome | |
# glyph information into Objective-C literals | |
# (Ends up being a big array of NSDictionary objects) | |
# Output is to stdout. Assumes icons.yml is in working directory. | |
# Copyright (c) 2013 iOSDeveloperZone.com | |
# MIT license -- See: http://opensource.org/licenses/MIT | |
require 'yaml' | |
# |
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
/* | |
CommonHMac defines the following enumeration | |
enum { | |
kCCHmacAlgSHA1, | |
kCCHmacAlgMD5, | |
kCCHmacAlgSHA256, | |
kCCHmacAlgSHA384, | |
kCCHmacAlgSHA512, | |
kCCHmacAlgSHA224 |
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
#!/bin/bash | |
if [[ $BASH_SOURCE != $0 ]]; then echo "$BASH_SOURCE must be executed, not sourced."; return 255; fi | |
# | |
# A script to fool iOS playgrounds into allowing access to CommonCrypto | |
# | |
# The script creates a dummy CommonCrypto.framework in the SDK's System | |
# Framework Library Directory with a module map that points to the | |
# umbrella header | |
# | |
# Usage: |
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
class Foo | |
{ | |
let a = "a" | |
let b = "b" | |
let c = "c" | |
let values = [ "A", "B", "C", "D", "E" ] | |
var rawValues: String | |
{ | |
let a = self.a |
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
/* ==== KeychainItem.swift === */ | |
public class KeychainItem { | |
public var dictionary : KeychainDictionary | |
public init() { | |
self.dictionary = KeychainDictionary() | |
} | |
public init(dictionary: KeychainDictionary) { |
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
OS X 10.10.1/Xcode 6.3 6D520o | |
inu:Radars idz$ swiftc main.swift | |
inu:Radars idz$ ./main -radar "is fixed" | |
[radar: is fixed] |
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
- (void)drawRect:(CGRect)rect { | |
[[UIColor lightGrayColor] setFill]; | |
[[UIColor darkGrayColor] setStroke]; | |
UIBezierPath *path = [[UIBezierPath alloc] init]; | |
CGPoint touchPoint = [self.lastTouch locationInView:self]; | |
CGFloat y0 = self.bounds.origin.y; | |
CGFloat weight = 0.75; // Vary from 0 - 1. Values closed to 1 are more pointy. | |
CGFloat y1 = y0 + (touchPoint.y - y0) * weight; // between top of screen and touch | |
CGFloat y2 = touchPoint.y; | |
CGFloat y4 = CGRectGetMaxY(self.bounds); |
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
func objectsAtIndexes<T:AnyObject>(array: [T], indexes:NSIndexSet) -> [T] | |
{ | |
return ((array as NSArray).objectsAtIndexes(indexes) as [T]) | |
} |
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 Foundation | |
let username = "username" | |
let password = "password" | |
let base = "https://api.github.com" | |
let user = "\(base)/user" | |
let url = NSURL(string: user) | |
let request = NSMutableURLRequest(URL: url!) |
OlderNewer