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 | |
// Inspired by https://gist.github.com/mbuchetics/c9bc6c22033014aa0c550d3b4324411a | |
struct JSONCodingKeys: CodingKey { | |
var stringValue: String | |
init?(stringValue: String) { | |
self.stringValue = stringValue | |
} |
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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
digits := math.Floor( math.Log10( x ) ) + 1 | |
guess := x/math.Pow(10,digits/2) |
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 fromString(string: String) -> UIColor { | |
var hash = 0 | |
let utf16array = Array(string.utf16) | |
for i in 0..<utf16array.count { | |
hash = Int(utf16array[i]) + ((hash << 5) - hash) | |
} | |
var colorValues = [CGFloat]() | |
for i in 0..<3 { | |
let value = (hash >> (i * 8)) & 0xFF | |
colorValues.append((CGFloat(value)/255.0)) |
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
######################### | |
# .gitignore file for Xcode4 and Xcode5 Source projects | |
# | |
# Apple bugs, waiting for Apple to fix/respond: | |
# | |
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation? | |
# | |
# Version 2.6 | |
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects | |
# |
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
let contactsGroup = dispatch_group_create() | |
dispatch_group_enter(contactsGroup) //Enter group for the first time | |
loadContactsFromServerAPIWithCompletion({ (contacts:[User]) -> () in | |
doStuffWithContacts(contacts) | |
dispatch_group_leave(contactsGroup) //Leave group | |
}) | |
dispatch_group_enter(contactsGroup) //Enter group again | |
loadContactsAddressBookWithCompletion({ (contacts:[User]) -> () in |
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 for spotlight indexing | |
protocol SpotlightIndexable { | |
var spotlightTitle: String {get} | |
var spotlightDescription: String {get} | |
var spotlightKeywords: [String] {get} | |
var spotlightImageData: NSData? {get} | |
var spotlightUrl: NSURL {get} | |
func index() | |
} |
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
formatDate=$(date "+%Y%m%d%H%M%S") | |
buildNumber="${formatDate}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${buildNumber}" "${PROJECT_DIR}/${INFOPLIST_FILE}" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${buildNumber}" "${SRCROOT}/<YOUR WATCHKIT APP FOLDER>/Info.plist" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${buildNumber}" "${SRCROOT}/<YOUR WATCHKIT EXTENSION FOLDER>/Info.plist" |
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
//If you have a Bridging-Header: | |
#import <FBSDKCoreKit/FBSDKCoreKit.h> | |
#import <FBSDKLoginKit/FBSDKLoginKit.h> | |
//In your AppDelegate: | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [String: AnyObject]?) -> Bool { | |
//App launch code | |
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) | |
//Optionally add to ensure your credentials are valid: |