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
// This widgets show approximate value of your music collection on discogs.com | |
// and the last addition to the collection in the background. | |
// Configuration: | |
// Your Discogs personal token generated here: https://www.discogs.com/settings/developers | |
let token = "..." | |
// Your Discogs username | |
let username = "..." | |
// Widget: |
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
/// https://sqlite.org/rescode.html | |
enum ResultCode: Int { | |
/// The SQLITE_OK result code means that the operation was successful and that there were no errors. Most other result codes indicate an error. | |
case ok = 0 | |
/// The SQLITE_ERROR result code is a generic error code that is used when no other more specific error code is available. | |
case error = 1 | |
/// The SQLITE_INTERNAL result code indicates an internal malfunction. In a working version of SQLite, an application should never see this result code. If application does encounter this result code, it shows that there is a bug in the database engine. | |
/// |
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
/// Lift operator (instance to function, function to function with one more parameter, key-path to function) | |
/// This operator is similar to `const` function from Haskell. | |
prefix operator ^ | |
/// Lift instance to function returning constant result. | |
@inline(__always) | |
prefix func ^ <T>(instance: @autoclosure @escaping () -> T) -> () -> T { | |
return instance | |
} |
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
#!/bin/bash | |
# Decompress all files (only some are compressed, primarily the newer ones) | |
for filename in *.gz | |
do | |
gzip -d $filename | |
done | |
# Convert all from GPX to GeoJSON | |
for filename in *.gpx | |
do | |
togeojson $filename > geojsons/$filename.geojson |
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
import XCTest | |
extension XCTestCase { | |
func assertFailScreenshot(_ closure: @autoclosure () -> Bool, message: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) { | |
if !closure() { | |
takeScreenshot(description: message, file: file, line: line, function: function) | |
if let message = message { | |
XCTFail(message) | |
} else { | |
XCTFail() |
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 UIView { | |
@IBInspectable var ignoresInvertColors: Bool { | |
get { | |
if #available(iOS 11.0, *) { | |
return accessibilityIgnoresInvertColors | |
} | |
return false | |
} | |
set { | |
if #available(iOS 11.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
import Foundation | |
final class DefaultsStore<Value: Codable> { | |
private let defaults: UserDefaults | |
private let encoder: PropertyListEncoder | |
private let decoder: PropertyListDecoder |
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
import Foundation | |
import FuntastyKit | |
import PromiseKit | |
import Photos | |
import Vision | |
import QuartzCore | |
protocol ImageClassificationService: Service { | |
func classify(asset: PHAsset) -> Promise<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
// We will offset the starting hue of every letter a bit | |
let startHue = CGFloat(offset) / CGFloat(layers.count) | |
// And also we offset the end hue a bit | |
// (We need to check if the hue is not larger than 1, then we use the remainder after dividing by 1 as a correct hue value) | |
let endHue = (CGFloat(offset + 1) / CGFloat(layers.count + 1)).truncatingRemainder(dividingBy: 1) | |
// And we create the colors from the hue values | |
let startColor = UIColor(hue: startHue, saturation: 1, brightness: 1, alpha: 1) | |
let endColor = UIColor(hue: endHue, saturation: 1, brightness: 1, alpha: 1) | |
// Finally, we create the animation similarly to the stroke end animation |
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
// Set duration for single animation | |
let duration: TimeInterval = 2 | |
// Enumerate all the layers | |
layers.enumerated().forEach { offset, layer in | |
// Create animation for each layer | |
let animation = CABasicAnimation(keyPath: "strokeEnd") | |
// Begin each animation after the one before | |
animation.beginTime = duration * CFTimeInterval(offset) + delay | |
animation.toValue = 1 | |
animation.duration = duration |
NewerOlder