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 centralManager(central: CBCentralManager, | |
| didDiscoverPeripheral peripheral: CBPeripheral, | |
| advertisementData: [String : AnyObject], | |
| RSSI: NSNumber) { | |
| guard let packet = advertisementData[CBAdvertisementDataLocalNameKey] as? String else { | |
| return | |
| } | |
| let version = Int(packet[packet.startIndex..<packet.startIndex.advancedBy(2)]) | |
| let channel = Int(packet[packet.startIndex.advancedBy(2)..<packet.startIndex.advancedBy(4)]) | |
| let cardRawValue = Int(packet[packet.startIndex.advancedBy(4)..<packet.startIndex.advancedBy(6)], radix: 16) |
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
| self.peripheral.startAdvertising([ | |
| CBAdvertisementDataLocalNameKey: "0001FE์ ์์ด", | |
| CBAdvertisementDataServiceUUIDsKey: [serviceUUID], | |
| ]) |
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
| public enum Card: Int { | |
| case Zero = 0 | |
| case Half = 127 | |
| case One = 1 | |
| case Two = 2 | |
| case Three = 3 | |
| case Five = 5 | |
| case Eight = 8 | |
| case Thirteen = 13 | |
| case Twenty = 20 |
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 CoreBluetooth | |
| let serviceUUID = CBUUID(string: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") | |
| let service = CBMutableService(type: serviceUUID, primary: true) | |
| /// 1. `CBCentralManager`๋ฅผ ์ด๊ธฐํํ๊ณ , | |
| self.central = CBCentralManager(delegate: self, queue: nil) | |
| /// 2. ์ฌ์ฉ๊ฐ๋ฅํ ์ํ๊ฐ ๋๋ฉด ํน์ UUID๋ฅผ ๊ฐ์ง ์๋น์ค๋ฅผ ์ค์บํฉ๋๋ค. | |
| func centralManagerDidUpdateState(central: CBCentralManager) { |
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 CoreBluetooth | |
| let serviceUUID = CBUUID(string: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") | |
| let service = CBMutableService(type: serviceUUID, primary: true) | |
| /// 1. `CBPeripheralManager`๋ฅผ ์ด๊ธฐํํ๊ณ , | |
| self.peripheral = CBPeripheralManager(delegate: self, queue: nil) | |
| /// 2. ์ฌ์ฉ๊ฐ๋ฅํ ์ํ๊ฐ ๋๋ฉด ํน์ UUID๋ฅผ ๊ฐ์ง ์๋น์ค๋ฅผ ์ถ๊ฐํ ๋ค์ | |
| func peripheralManagerDidUpdateState(peripheral: CBPeripheralManager) { |
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 Reactor { | |
| public func plugin<PluginReactor>( | |
| keyPath: KeyPath<State, PluginReactor?>, | |
| mutation mutationFactory: @escaping (PluginReactor) -> Mutation | |
| ) -> Observable<Mutation> where PluginReactor: Reactor { | |
| return self.stateDidCreate.flatMapLatest { [weak self] () -> Observable<Mutation> in | |
| guard let `self` = self else { return .empty() } | |
| return self.state.flatMapLatest { state -> Observable<Mutation> in | |
| guard let pluginReactor = state[keyPath: keyPath] else { return .empty() } | |
| let pluginStates = Observable.merge(pluginReactor.state.skip(1)) |
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
| # ์ค์ API | |
| def get_collections(serializer): | |
| collections = orm.foo() | |
| paging = orm.bar() | |
| return serializer.serialize(items=collections, paging=paging) | |
| # ํ ์คํธ | |
| def test_serializer_get_collections(): | |
| collections = fixture_collections() | |
| paging = fixture_paging() |
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 ObservableType where E: Any { | |
| func map<T: ImmutableMappable>(_ mappableType: T.Type) -> Observable<T> { | |
| return self | |
| .map { try Mapper<T>().map(JSONObject: $0) } | |
| .do(onError: { error in | |
| if error is MapError { | |
| log.error(error) | |
| } | |
| }) | |
| } |
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
| // | |
| // ๋ฐฐ์ด๊ณผ ํด๋ก์ ํ์ฉ | |
| // | |
| [1, 3, 6, 2, 7, 9] | |
| .filter { $0 % 2 == 0 } // ์ง์ ํํฐ๋ง | |
| .map { $0 * 2 } // ๋ชจ๋ ๊ฐ์ ๊ณฑํ๊ธฐ 2 | |
| .reduce(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
| /* | |
| ๋ญ๊ฐ ํผ์ฆ๊ฐ์ RxSwift ์ง๋ฌธ์ ๋๋ค. | |
| ์๋ฒ์ 3 ํ์ด์ง์ ๋ถ๋์ ํ๊บผ๋ฒ์ ์์ฒญํ๋ ค๋๋ฐ, | |
| ์์ฒญ์ ๋์์ ๋ณด๋ด๊ณ ์๋ต์ ์์๋๋ก ์ฒ๋ฆฌํ๊ณ ์ถ์ต๋๋ค. | |
| ํ ์คํธ ์๋๋ฆฌ์ค: | |
| ๊ฐ ์์ฒญ(Observable)๋ค์ subscribe ๋ ๋ request๊ฐ ์์ | |
| ๊ฐ ์์ฒญ์ request์๋ 2, 4, 2์ด์ฉ ๊ฑธ๋ฆฐ๋ค๊ณ ๊ฐ์ | |
| -> 2์ด ํ ์ฒซ ํ์ด์ง๊ฐ ๋จ๊ณ | |
| -> ์ถ๊ฐ๋ก 2์ด ํ ๋๋จธ์ง๊ฐ ์ ๋ถ ๋จ๋ | |
| ์ํฉ์ ์ํ๊ณ ์์ต๋๋ค. |