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
- [ ] %| | mtd | |
[%filltext:name=the title:default=here%](%clipboard) | lnk | |
 | img | |
```%filltext:name=lang% %| ``` | fence | |
**%clipboard** | bld | |
~~%clipboard~~ | strike | |
<img width="%filltext:name=width:default=320%" alt="%filltext:name=img:default=img%" src="https://dl.dropboxusercontent.com/u/2559476/%clipboard"> | rimg | |
``` %clipboard%| ``` | fe | |
* [[%clipboard]] | sbi | |
_%clipboard_ | italic |
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 | |
protocol ILayout{ | |
init(_ args:Double...) | |
} | |
class Fillet:ILayout{ | |
required init(_ args:Double...){ | |
Swift.print("Fillet: " + "\(args.count)") | |
} | |
} | |
class Margin:ILayout{ |
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
private func createDisplayLink() { | |
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink) | |
guard let displayLink = displayLink else { | |
return | |
} | |
let callback: CVDisplayLinkOutputCallback = { (_, _, _, _, _, userInfo) -> CVReturn in | |
let myView = Unmanaged<MyView>.fromOpaque(COpaquePointer(userInfo)).takeUnretainedValue() | |
dispatch_async(dispatch_get_main_queue()) { | |
myView.update() |
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
//terminal script:(takes 3 sec to setup) http://stackoverflow.com/questions/12306223/how-to-manually-create-icns-files-using-iconutil | |
//or drag and drop solution (sketchy website, download is a hex file, no link to devs): https://iconverticons.com/online/ | |
Here's a script to convert a 1024x1024 png (named "Icon1024.png") to the required icns file. Save it to a filed called "CreateICNS.src" in the folder where your png file is then in terminal "cd" to the same folder and type "source CreateICNS.src" to call it: | |
mkdir MyIcon.iconset | |
sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png | |
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_16x16@2x.png | |
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png | |
sips -z 64 64 Icon1024.png --out MyIcon.iconset/icon_32x32@2x.png |
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 Security | |
class Keychain { | |
class func save(key: String, data: NSData) -> Bool { | |
let query = [ | |
kSecClass as String : kSecClassGenericPassword as String, | |
kSecAttrAccount as String : key, | |
kSecValueData as String : data ] |
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 plainString = "foo" | |
// Encoding | |
guard let plainData = (plainString as NSString).dataUsingEncoding(NSUTF8StringEncoding) else { | |
fatalError() | |
} | |
let base64String = plainData.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) | |
print(base64String) // Zm9v |
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 | |
/* | |
* TODO: Implement the immediate variable if its needed (it would be a way to get assert the 1-level down immediate child an event came from, rather than the origin child which can be many levels deeper in the hirarchy) | |
*/ | |
class Event{ | |
static var update:String = "eventUpdate"/*Idealy I would name this change but apparently then subclasses can name their const the same*/ | |
var type:String | |
var origin:AnyObject/*origin sender of event, this could also be weak if you discover a memory leak*/ | |
/*var immediate:Any?*///prev sender of event, may be implemented in the future if needed |
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 AppKit | |
public extension NSBezierPath { | |
public convenience init(path: CGPath) { | |
self.init() | |
let pathPtr = UnsafeMutablePointer<NSBezierPath>.alloc(1) | |
pathPtr.initialize(self) | |
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 | |
/// Given pointer to first element of a C array, invoke a function for each element | |
func enumerateCArray<T>(array: UnsafePointer<T>, count: UInt32, f: (UInt32, T) -> ()) { | |
var ptr = array | |
for i in 0..<count { | |
f(i, ptr.memory) | |
ptr = ptr.successor() | |
} | |
} |
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
class DirectoryObserver { | |
deinit { | |
dispatch_source_cancel(source) | |
close(fileDescriptor) | |
} | |
init(URL: NSURL, block: dispatch_block_t) { |
OlderNewer