A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
// | |
// Created by はるふ on 2017/12/11. | |
// Copyright © 2017年 ha1f. All rights reserved. | |
// | |
import Foundation | |
import CoreImage | |
import AVFoundation | |
extension CIFilter { |
- (void)setupCaptureSession | |
{ | |
NSError *error = nil; | |
AVCaptureSession *session = [[AVCaptureSession alloc] init]; | |
session.sessionPreset = AVCaptureSessionPresetMedium; | |
AVCaptureDevice *device = [AVCaptureDevice | |
defaultDeviceWithMediaType:AVMediaTypeVideo]; |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
import Foundation | |
import UIKit | |
// Usage Examples | |
let shadowColor = Color.shadow.value | |
let shadowColorWithAlpha = Color.shadow.withAlpha(0.5) | |
let customColorWithAlpha = Color.custom(hexString: "#123edd", alpha: 0.25).value | |
enum Color { | |
import Foundation | |
import UIKit | |
// Usage Examples | |
let system12 = Font(.system, size: .standard(.h5)).instance | |
let robotoThin20 = Font(.installed(.RobotoThin), size: .standard(.h1)).instance | |
let robotoBlack14 = Font(.installed(.RobotoBlack), size: .standard(.h4)).instance | |
let helveticaLight13 = Font(.custom("Helvetica-Light"), size: .custom(13.0)).instance | |
struct Font { |