This file contains hidden or 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
| //original video https://realm.io/news/pragma-chris-eidhof-swift-c/ | |
| import Foundation | |
| extension Comparable { | |
| static func compare (l: UnsafePointer<Void>, _ r: UnsafePointer<Void>) -> Int32 { | |
| let left: Self = UnsafePointer(l).memory | |
| let right: Self = UnsafePointer(r).memory | |
| if left < right { return -1 } | |
| if left == right { return 0 } |
This file contains hidden or 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
| #copy directory hierarchy without files | |
| pathFrom$ find . -type d -exec mkdir -p /pathTo/{} \; |
This file contains hidden or 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
| // Swift Standard Librray - String | |
| // Keith Harrison http://useyourloaf.com | |
| // Import Foundation if you want to bridge to NSString | |
| import Foundation | |
| // ==== | |
| // Initializing a String | |
| // ==== |
This file contains hidden or 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
| "Author: Zoltán Bognár | |
| "put into ~/ | |
| syntax enable | |
| set hls | |
| highlight Search guibg=#7D2F52 | |
| set bg=light | |
| set tabstop=4 | |
| set softtabstop=4 | |
| set shiftwidth=4 | |
| set scrolloff=2 |
This file contains hidden or 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
| // | |
| // Macros.swift | |
| // | |
| // Created by Xavier Muñiz on 6/12/14. | |
| import Foundation | |
| // dLog and aLog macros to abbreviate NSLog. | |
| // Use like this: |
This file contains hidden or 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 Array { | |
| func groupBy<G: Hashable>(groupClosure: (Element) -> G) -> [[Element]] { | |
| var groups = [[Element]]() | |
| for element in self { | |
| let key = groupClosure(element) | |
| var active = Int() | |
| var isNewGroup = true | |
| var array = [Element]() |
This file contains hidden or 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 uniq<S: SequenceType, E: Hashable where E==S.Generator.Element>(source: S) -> [E] { | |
| var seen: [E:Bool] = [:] | |
| return source.filter { seen.updateValue(true, forKey: $0) == nil } | |
| } |
This file contains hidden or 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 come from bash you might have to change your $PATH. | |
| # export PATH=$HOME/bin:/usr/local/bin:$PATH | |
| # Path to your oh-my-zsh installation. | |
| export ZSH=/Users/alex-potapov/.oh-my-zsh | |
| # Set name of the theme to load. Optionally, if you set this to "random" | |
| # it'll load a random theme each time that oh-my-zsh is loaded. | |
| # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
| ZSH_THEME="robbyrussell" |
This file contains hidden or 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
| //Copyright | |
| //https://habrahabr.ru/post/271647/ | |
| import Foundation | |
| // Summ and Substraction of Vectors | |
| func +(left: CGPoint, right: CGPoint)->CGPoint{ | |
| return CGPoint(x: left.x+right.x, y: left.y+right.y) | |
| } | |
| prefix func -(right: CGPoint)->CGPoint{ |
This file contains hidden or 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
| /// Wraps the observer token received from | |
| /// NotificationCenter.addObserver(forName:object:queue:using:) | |
| /// and unregisters it in deinit. | |
| final class NotificationToken: NSObject { | |
| let notificationCenter: NotificationCenter | |
| let token: Any | |
| init(notificationCenter: NotificationCenter = .default, token: Any) { | |
| self.notificationCenter = notificationCenter | |
| self.token = token |