Skip to content

Instantly share code, notes, and snippets.

View memfrag's full-sized avatar

Martin Johannesson memfrag

View GitHub Profile
import Foundation
import Compression
/// A convenience class for compressing an NSData object.
///
/// Example:
/// ```
/// let compression = Compression(algorithm: .ZLIB)
/// let compressedData = compression.compressData(data)
/// let decompressedData = compresison.decompressData(compressedData)
@memfrag
memfrag / .gitignore
Created April 8, 2017 09:43
.gitignore
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@memfrag
memfrag / IDETemplateMacros.plist
Last active August 26, 2017 12:55
Put file in ~/Library/Developer/Xcode/UserData or <Project>.xcodeproj/xcshareddata/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
// ___COPYRIGHT___
//</string>
</dict>
</plist>
import Foundation
private class Nothing: Decodable { }
func decodeArray<T, U: Decodable>(_ container: KeyedDecodingContainer<T>, forKey key: T) throws -> [U] {
var unkeyedContainer = try container.nestedUnkeyedContainer(forKey: key)
var objects: [U] = []
while !unkeyedContainer.isAtEnd {
do {
let object = try unkeyedContainer.decode(U.self)
@memfrag
memfrag / .swiftlint.yml
Created February 17, 2019 20:01
SwiftLint rules
whitelist_rules: # only these rules will be applied
- line_length
- file_length
- function_body_length
- type_body_length
- type_name
- identifier_name
- class_delegate_protocol
- weak_delegate
- anyobject_protocol
import Cocoa
enum Animal {
case aardvark(NSWindow.StyleMask)
case bear
case cat
}
func isNotCat(_ animal: Animal) -> Bool {
switch animal {