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 | |
struct JSONStringRawRepresentable<T: Codable>: RawRepresentable { | |
typealias RawValue = String | |
var value: T | |
init(value: T) { | |
self.value = value | |
} |
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
### Keybase proof | |
I hereby claim: | |
* I am cemaleker on github. | |
* I am cemaleker (https://keybase.io/cemaleker) on keybase. | |
* I have a public key ASDxNd1ZEbA37ckIj89Su08jqHW29FCUY3ZSkMlTm9N0Qwo | |
To claim this, I am signing this object: |
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
enum StringRepresentableType: String { | |
case foo | |
case bar | |
} | |
typealias JSONDictionary = [String: Any] | |
extension JSONDictionary { | |
func value<T, R>(for key: String) -> T? where T: RawRepresentable, T.RawValue == R { |
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
Sample gapless test files with required metadata. |
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
var baz: String? | |
func deferSomething(_ quux: inout String?) { | |
var foo: String | |
quux = "uier" | |
defer { print("__\(foo)__\(baz)__\(quux)__") } | |
quux = "grault" | |
foo = "bar" | |
} | |
func dontDeferSomething(_ quux: inout String?) { |
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 Sequence { | |
/// return a sorted collection using a stable sort algorithm | |
/// | |
/// - Parameter areInIncreasingOrder: return nil when two element are equal | |
/// - Returns: the sorted collection | |
/// | |
/// Shamelessly copied from https://stackoverflow.com/a/45585365 | |
/// | |
public func stableSorted(by areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> [Element] { |
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
<?php | |
function __rd_dirname($path) { | |
$path = dirname($path); | |
return __rd_resolve_real($path); | |
} | |
function __rd_resolve_real($path) { | |
return realpath(is_link($path) ? readlink($path) : $path); | |
} |
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 UIViewController { | |
func attachChildViewController(_ viewController: UIViewController) { | |
attachChildViewController(viewController, to: self.view) | |
} | |
func attachChildViewController(_ viewController: UIViewController, to view: UIView) { | |
self.addChildViewController(viewController) | |
view.addSubview(viewController.view) | |
viewController.didMove(toParentViewController: self) |