├── app
│ ├── controllers
│ │ ├── admin
│ │ │ ├── posts.js
│ │ │ └── users.js
│ │ ├── posts.js
│ │ ├── session.js
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
#!/bin/bash | |
# | |
# git-mv-with-history -- move/rename file or folder, with history. | |
# | |
# Moving a file in git doesn't track history, so the purpose of this | |
# utility is best explained from the kernel wiki: | |
# | |
# Git has a rename command git mv, but that is just for convenience. | |
# The effect is indistinguishable from removing the file and adding another | |
# with different name and the same content. |
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
// USAGE: | |
// Call RestorationDefender.printViewControllerClassesThatAreProbablyNotRestorable() to print a list of view controllers that will probably not return from state restoration. | |
// Call RestorationDefender.crashWhenViewControllersDoNotImplementStateRestoration() to crash your app when a view controller appears without setting restorationIdentifier and restorationClass. | |
// Call RestorationDefender.shoutWhenViewControllersDoNotImplementStateRestoration() to print a big message when a view controller appears without setting restorationIdentifier and restorationClass. | |
import Foundation | |
private func objc_getClassList() -> [AnyClass] { | |
let expectedClassCount = objc_getClassList(nil, 0) | |
var allClasses = UnsafeMutablePointer<AnyClass?>.alloc(Int(expectedClassCount)) |
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
so A and B are structurally identical | |
C reverses the order of the 8 and 32 bit Ints | |
and D substitutes a string for the Int8 | |
then I try to read aaaa’s bits using B C and D overlays 😊 | |
C is printing the 8 bits of the A integer j and then the first 8 bits of integer k but somehow that still works out to one | |
when I hit D it doesn’t find a string so prints a blank | |
but the important point is: it doesn’t check anything, and doesn’t crash |
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 | |
func withCStrings(_ strings: [String], scoped: ([UnsafeMutablePointer<CChar>?]) throws -> Void) rethrows { | |
let cStrings = strings.map { strdup($0) } | |
try scoped(cStrings + [nil]) | |
cStrings.forEach { free($0) } | |
} | |
enum RunCommandError: Error { | |
case WaitPIDError |
https://swift.org/documentation/api-design-guidelines/
-
사용할 때 기준으로 명확하게 작성하는 게 가장 중요한 지향점이다. 메소드나 프로퍼티 같은 개발 요소는 한 번만 선언하고 반복적으로 사용한다. API를 만들 때는 사용하기 명확하고 편하게 만들어야 한다. 설계를 검증할 때 선언 부분을 읽는 것만으로는 부족하다. 그 대신 사용하는 상황에서 맥락에 맞고 명확한 지 늘 고려해야 한다.
-
명확한 표현이 압축한 간결성보다 더 중요하다. 스위프트 코드는 압축해서 간결하게 작성할 수 있지만, 단지 글자수를 줄여서 가장 짧은 코드를 만드는 게 목표는 아니다. 스위프트 코드의 간결성은 자연스럽게 반복적으로 재사용하는 코드(boilerplate)를 줄이는 기능과 강한 타입 시스템의 부수효과로 드러날 뿐이다.
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 UIKit | |
private func isExcluded(_ kind: AnyClass) -> Bool { | |
let name = String(describing: kind) | |
return (name.count > 2 && name.prefix(2) == "UI") || | |
(name.count > 3 && name.prefix(3) == "_UI") | |
} | |
extension UIControl { | |
override open var accessibilityIdentifier: 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
import Foundation | |
class ReadValue { | |
var successClosure : ((String)->())? = nil | |
var value : String = "" { | |
didSet { | |
if let closure = successClosure { | |
closure(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
class ReadValue { | |
private var thread : Thread? = nil | |
init(with handler: @escaping (String) -> ()) { | |
thread = Thread(block: { | |
while(true) { | |
let value = readLine() ?? "" | |
handler(value) | |
} | |
}) | |
thread?.start() |
- Read DataLoader Source
- Check out Keechma's Dataloader and Graphql Builder... (video)
- Check out this example with GraphQL + Express + Dataloader
OlderNewer