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
// | |
// AppDelegateHandler.swift | |
// Pods | |
// | |
// Created by Andrey Zarembo on 10.02.16. | |
// | |
// | |
import Foundation |
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
- (NSString*)hexStringFromString:(NSString*)string | |
{ | |
const char *utf8 = [string UTF8String]; | |
NSMutableString *result = [NSMutableString new]; | |
for (int i = 0; i < string.length; i++) { | |
[result appendFormat:@"0x%02X, ", *utf8++ & 0x00FF]; | |
} | |
return result; | |
} |
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 | |
final class TimeProfiler { | |
typealias TimeMeasurementTimestamp = TimeInterval | |
public typealias TimeMeasurementDescription = String | |
public static func measure<R>( | |
description: TimeMeasurementDescription, | |
action: (() throws -> (R))) |
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 | |
final class ConcurrentPerformer { | |
func perform<T>(_ objects: [T], iterations: Int? = nil, action: ((T) -> ())) { | |
if let iterations = iterations { | |
customPerform(objects, iterations: iterations, action: action) | |
} else { | |
defaultPerform(objects, action: action) | |
} |
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 toMainThread<T>(_ closure: @escaping (T) -> ()) -> ((T) -> ()) { | |
return { obj in | |
if Thread.isMainThread { | |
closure(obj) | |
} else { | |
DispatchQueue.main.async { | |
closure(obj) | |
} | |
} | |
} |
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 | |
extension Dictionary { | |
func enumerateKeysAndObjects( | |
options opts: NSEnumerationOptions = [], | |
using block: (Any, Any, UnsafeMutablePointer<ObjCBool>) throws -> Void) throws | |
{ | |
var blockError: Error? | |
(self as NSDictionary).enumerateKeysAndObjects(options: opts) { (key, obj, stops) 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
import Foundation | |
public extension Array { | |
public func asyncConcurrentEnumerated( | |
each: (_ object: Element, _ completion: @escaping () -> (), _ stop: () -> ()) throws -> ()) throws | |
{ | |
let dispatchGroup = DispatchGroup() | |
let array = NSArray(array: self) | |
var eachError: Error? | |
array.enumerateObjects(options: .concurrent) { obj, key, stop 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
#!/bin/sh | |
# Print all the commands in script before their execution | |
# export PS4='+ 6: ' | |
set -x | |
# Force the script to stop if any unhandled error occurs (i.e. an error not handled with `||`) | |
# set -e | |
# Force the script to stop if any uninitialized variable is used |
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 SomeProtocol { | |
func someMethod0() | |
func someMethod1() | |
func someMethod2() | |
func someMethod3() | |
func someMethod4() | |
func someMethod5() | |
func someMethod6() | |
func someMethod7() |
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
require 'net/http' | |
require 'json' | |
require 'io/console' | |
args = Hash[ ARGV.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/) ] | |
controller_url = args['controller'] | |
if controller_url.nil? | |
raise "You need to specify the controller: --controller=http://anka.controller.net" | |
end |
OlderNewer