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 JSONDecoder { | |
enum DateDecodeError: String, Error { | |
case invalidDate | |
} | |
static var bestDateAttemptDecoder: JSONDecoder { | |
let decoder = JSONDecoder() | |
decoder.dateDecodingStrategy = .custom({ (decoder) -> Date in | |
let container = try decoder.singleValueContainer() | |
if let dateSecs = try? container.decode(Double.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
[ | |
{ | |
"constant": true, | |
"inputs": [ | |
{ | |
"name": "_name", | |
"type": "string" | |
} | |
], | |
"name": "howManyKittensCalled", |
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
💩 | |
👻 | |
🤖 | |
🎃 | |
🤡 | |
🦅 | |
🐢 | |
🐔 | |
🐧 | |
👁 |
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
func emojiHash(_ input: String) -> String { | |
// HashEmoji.txt is a line separated file of 256 emojis (1 per byte) | |
// https://gist.github.com/th3m477/c0b306fd7992459f366e1a49fe0520d2 | |
guard let path = Bundle.main.path(forResource: "HashEmoji", ofType: "txt"), | |
let emojiData = try? String(contentsOfFile: path, encoding: .utf8) | |
else { | |
preconditionFailure("HashEmoji resource not available") | |
} | |
let emojis = emojiData.components(separatedBy: .newlines) |
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
const RECONNECT_MILLIS = 2000 | |
class Web3Connection { | |
constructor() { | |
this.connect() | |
} | |
async connect() { | |
const provider = new Web3.providers.WebsocketProvider('...') |
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 NSLayoutAnchor { | |
@objc @discardableResult func eq(_ anchor: NSLayoutAnchor, _ constant: CGFloat = 0.0) -> NSLayoutConstraint { | |
let c = constraint(equalTo: anchor, constant: constant) | |
c.isActive = true | |
return c | |
} | |
@objc @discardableResult func lte(_ anchor: NSLayoutAnchor, _ constant: CGFloat = 0.0) -> NSLayoutConstraint { | |
let c = constraint(lessThanOrEqualTo: anchor, constant: constant) | |
c.isActive = true |