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
init(configuration: AWSServiceConfiguration) { | |
super.init() | |
var urlString = "https://xxxxxxxxxx.execute-api.{region}.amazonaws.com/{stage名}" | |
if urlString.hasSuffix("/") { | |
urlString = String(urlString.dropLast()) | |
} | |
self.configuration = AWSServiceConfiguration( | |
region: configuration.regionType, | |
endpoint: AWSEndpoint(region: configuration.regionType, service: .APIGateway, url: URL(string: urlString)), |
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
/// 空文字などのURLが作れない文字列でもデコードに成功する型を用意 | |
struct RobustURL: Codable, RawRepresentable { | |
let rawValue: String | |
var typed: URL? { | |
return URL(string: rawValue) | |
} | |
} | |
/// CGSizeと互換性があるのは | |
/// {"width": Number, "height": Number} じゃなくて |
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
document.location.href = "twitter://post?message=" + encodeURIComponent(getSelection().focusNode.wholeText) |
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
(function() { | |
var lastIndents = null; | |
var lastNode = null; | |
var lastParsedLine = null; | |
function stringify(node, indents) { | |
const text = node.children(".name").children(".content").text(); | |
var lines = []; |
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 | |
extension JSONDecoder { | |
func decode<T: Decodable>(from data: Data) throws -> T { | |
return try decode(T.self, from: data) | |
} | |
} | |
extension PropertyListDecoder { | |
func decode<T: Decodable>(from data: Data) throws -> T { | |
return try decode(T.self, from: data) |
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
//付属型メンバーを持つ抽象型 Abstract1 を定義 | |
protocol Abstract1 { | |
associatedtype A | |
associatedtype B | |
func tellMyType(a: A) -> Self.Type | |
} | |
//付属型メンバーを持つ抽象型 Abstract2 を定義 | |
protocol Abstract2 { | |
associatedtype E | |
var element: E { get } |
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
func decodeJSON<T: Decodable>(_ t: T.Type, from string: String) { | |
let data = string.data(using: .utf8)! | |
let decoder = JSONDecoder() | |
let s = try! decoder.decode(t, from: data) | |
print(s) | |
} | |
struct Robustness: Decodable { | |
let name: 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
import UIKit | |
func decodeJSON<T: Decodable>(_ t: T.Type, from string: String) { | |
let data = string.data(using: .utf8)! | |
let decoder = JSONDecoder() | |
let s = try! decoder.decode(t, from: data) | |
print(s) | |
} |
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 | |
protocol P { | |
var name: String { get } | |
} | |
class C: P { | |
var name: String | |
init(name: String) { | |
self.name = name | |
} |
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 | |
func address(_ o: UnsafeRawPointer) -> String { | |
return String( | |
format: "%p", | |
Int(bitPattern: o) | |
) | |
} | |
let array = [1,2,3] |