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
// | |
// ACAppDelegate.m | |
// SocketTest | |
// | |
// Created by Izzy Fraimow on 11/19/12. | |
// | |
#import "ACAppDelegate.h" | |
#include <arpa/inet.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
//: Playground - noun: a place where people can play | |
import Foundation | |
// DispatchGroup sample. | |
// we are waiting for all async blocks to be finished before typing "[Dispatch Group] sample has finished" | |
let group = DispatchGroup() | |
let q1 = DispatchQueue.global(qos: .background) | |
let q2 = DispatchQueue.global(qos: .background) |
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
var graph1 = { | |
vertex: ["1","2","3"], | |
edge: [, | |
/* vertex1, vertex2, weight */ | |
["1", "2", 4], | |
["1", "3", 7], | |
["2", "3", 1] | |
] | |
}, | |
graph2 = { |
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
/** | |
* Basic Graph data structure implementation | |
* @constructor | |
*/ | |
var Graph = function() { | |
this.vertices = {}; | |
}; | |
Graph.prototype.add = function(name, edges) { | |
edges = edges || null; |
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
// | |
// NSOperationQueue+Completion.h | |
// QueueTest | |
// | |
// Created by Artem Stepanenko on 23.11.13. | |
// Copyright (c) 2013 Artem Stepanenko. All rights reserved. | |
// | |
typedef void (^NSOperationQueueCompletion) (void); |
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
###################### | |
# Options | |
###################### | |
REVEAL_ARCHIVE_IN_FINDER=false | |
FRAMEWORK_NAME="${PROJECT_NAME}" | |
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework" |
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
extension PHPhotoLibrary { | |
typealias PhotoAsset = PHAsset | |
typealias PhotoAlbum = PHAssetCollection | |
static func saveImage(image: UIImage, albumName: String, completion: (PHAsset?)->()) { | |
if let album = self.findAlbum(albumName) { | |
saveImage(image, album: album, completion: completion) | |
return | |
} |
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 notified = dispatch_semaphore_create(0) | |
let group = dispatch_group_create() | |
let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) | |
for n in 0..<20 { | |
dispatch_group_async(group, queue) { | |
let timeInterval = Double(arc4random_uniform(1000)) * 0.01 |
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
/** | |
http://mythosil.hatenablog.com/entry/20111017/1318873155 | |
http://blog.dealforest.net/2012/03/ios-android-per-aes-crypt-connection/ | |
*/ | |
@interface NSData (AES) | |
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key; | |
- (NSData *)AES128DecryptedDataWithKey:(NSString *)key; | |
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key iv:(NSString *)iv; |
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 | |
import SystemConfiguration.CaptiveNetwork | |
func getWiFiSsid() -> String? { | |
var ssid: String? | |
if let interfaces = CNCopySupportedInterfaces() as NSArray? { | |
for interface in interfaces { | |
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? { | |
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String | |
break |
OlderNewer