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 NonNullConnection(graphene.relay.Connection): | |
class Meta: | |
abstract = True | |
@classmethod | |
def __init_subclass_with_meta__(cls, node=None, **options): | |
if node is not None and not isinstance(node, graphene.NonNull): | |
node = graphene.NonNull(node) | |
super(NonNullConnection, cls).__init_subclass_with_meta__( |
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 UIBezierPath { | |
/// https://github.com/jnfisher/ios-curve-interpolation/blob/master/Curve%20Interpolation/UIBezierPath%2BInterpolation.m | |
func catmullRomInterpolate(with points: [CGPoint], alpha: CGFloat = 0.3) { | |
guard points.count >= 4 else { return self.hermiteInterpolate(with: points, alpha: alpha) } | |
let startIndex = 1 | |
let endIndex = points.count - 2 | |
for currentIndex in 1..<endIndex { | |
let prevIndex = currentIndex - 1 |
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 | |
import PlaygroundSupport | |
let width: CGFloat = 200 | |
let height: CGFloat = 100 | |
let spacing: CGFloat = 10 | |
let numberOfViews: Int = 5 | |
let canvas = UIView(frame: CGRect( | |
x: 0, |
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 | |
public enum Swinject { | |
public final class Container { | |
} | |
} | |
protocol Assembly { | |
func assemble(to container: Swinject.Container) | |
} |
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 io | |
import requests | |
import subprocess | |
import zipfile | |
FIREBASE_VERSION = '6.29.0' | |
def main(): | |
json_urls = [ | |
"https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json", |
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
final class NSStatusBarStub: NSStatusBar { | |
override func statusItem(withLength length: CGFloat) -> NSStatusItem { | |
let alloc = NSStatusItem.perform(NSSelectorFromString("alloc"))!.takeRetainedValue() as! NSStatusItem | |
let selector = NSSelectorFromString("_initInStatusBar:withLength:withPriority:hidden:") | |
let imp = alloc.method(for: selector) | |
typealias ObjcInitBlock = @convention(c) (NSStatusItem, Selector, NSStatusBar, CGFloat, Int, Bool) -> NSStatusItem | |
let initializer = unsafeBitCast(imp, to: ObjcInitBlock.self) | |
let statusItem = initializer(alloc, selector, self, length, 1, true) // it won't work the last parameter("hidden") is set to `false` |
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
protocol ContainerProtocol { | |
associatedtype Service | |
associatedtype Nested: ContainerProtocol | |
var service: Service { get } | |
var nestedContainer: () -> Nested { get } | |
} | |
struct TypedContainer<Service, Nested: ContainerProtocol>: ContainerProtocol { | |
let service: Service |
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
let source = Observable<(Int, Int)>.from([ | |
(0, 1), | |
(2, 3), | |
(4, 5), | |
]) | |
// Doesn't work as expected | |
// A -> (0, 1) | |
source | |
.distinctUntilChanged(==) |
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
repositoryMap: | |
- FirebaseAnalyticsBinary: | |
- name: FIRAnalyticsConnector | |
- name: Firebase | |
- name: FirebaseAnalytics | |
- name: FirebaseCore | |
- name: FirebaseCoreDiagnostics | |
- name: FirebaseInstallations | |
- name: GoogleAppMeasurement | |
- name: GoogleDataTransport |
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 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) { |