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
// | |
// TableViewController.swift | |
// RSSParser | |
// | |
// Created by mihael on 14/04/15. | |
// Copyright (c) 2015 Mihael Isaev inc. All rights reserved. | |
// | |
import UIKit |
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 UIKit | |
import AVFoundation | |
class ViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate { | |
@IBOutlet weak var myView: UIView! | |
var session: AVCaptureSession? | |
var device: AVCaptureDevice? | |
var input: AVCaptureDeviceInput? |
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
// | |
// HMAC.swift | |
// | |
// Created by Mihael Isaev on 21.04.15. | |
// Copyright (c) 2014 Mihael Isaev inc. All rights reserved. | |
// | |
// *********************************************************** | |
// | |
// How to import CommonCrypto in Swift project without Obj-c briging header | |
// |
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
{ | |
"countries":[ | |
{ | |
"name":"Afghanistan", | |
"phoneCode":"93", | |
"iso":"AF" | |
}, | |
{ | |
"name":"Albania", | |
"phoneCode":"355", |
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 NSTimeZone { | |
func offsetStringFromGMT() -> String { | |
var offsetSeconds = secondsFromGMT | |
var offsetString = "+00:00" | |
var offsetSymbol = "+" | |
var offsetHoursLeadString = "0" | |
var offsetMinutesLeadString = "0" | |
if offsetSeconds < 0 { | |
offsetSymbol = "-" | |
offsetSeconds = (offsetSeconds * -1) |
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 | |
limit="${1-10000000}"; | |
echo "Keeping SourceKitService below $limit KiB of virtual memory." | |
echo "Hit ^C to quit." | |
while true; do | |
sleep 1; | |
p=`pgrep ^SourceKitService$` | |
if [ -n "$p" ]; then | |
vsz=`ps -o vsz -p "$p" | tail -1` |
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 Vapor | |
extension Request { | |
func promise<T>(_ asyncCode: @escaping (() throws ->(T))) -> Future<T> where T: ResponseEncodable { | |
let promise = eventLoop.newPromise(T.self) | |
DispatchQueue.global().async { | |
do { | |
promise.succeed(result: try asyncCode()) |
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 PostgreSQL | |
typealias PostgreSQLQueryRow = [PostgreSQLColumn: PostgreSQLData] | |
extension Dictionary where Key == PostgreSQLColumn, Value == PostgreSQLData { | |
func decode<T>(_ key: String) throws -> T where T: PostgreSQLDataConvertible { | |
guard let v = try firstValue(forColumn: key)?.decode(T.self) else { | |
throw PostgreSQLError(identifier: "decodingError", reason: "Unable to decode \"\(key)\" column ", source: .capture()) | |
} | |
return v |
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
public func boot(_ app: Application) throws { | |
let config = URLSessionConfiguration.default | |
config.requestCachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalCacheData | |
config.connectionProxyDictionary = [AnyHashable: Any]() | |
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPEnable as String] = 1 | |
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPProxy as String] = "proxy-server.com" | |
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPPort as String] = 8080 | |
let session = URLSession.init(configuration: config) | |
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 String { | |
var snakeCased: String { | |
var newString: String = "" | |
let upperCase = CharacterSet.uppercaseLetters | |
for scalar in self.unicodeScalars { | |
if upperCase.contains(scalar) { | |
if newString.count > 0 { | |
newString.append("_") | |
} | |
let character = Character(scalar) |
OlderNewer