class MyCell: UITableViewCell {
let gradientLayer = CAGradientLayer()
}
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
// MARK: - Wrapper | |
@propertyWrapper | |
struct SomeKindOfBool: Decodable { | |
var wrappedValue: Bool | |
init(from decoder: Decoder) throws { | |
let container = try decoder.singleValueContainer() | |
if let stringifiedValue = try? container.decode(String.self) { | |
switch stringifiedValue.lowercased() { | |
case "false", "no", "0", "n", "f": wrappedValue = 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
import UIKit | |
class PixelWidthConstraint: NSLayoutConstraint { | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
constant = 1.0 / UIScreen.main.scale | |
} | |
} |
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
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off; | |
server { | |
listen 443 ssl http2 default_server; | |
listen [::]:443 ssl http2 default_server; | |
server_name example.com; | |
location /api/ { | |
# Rate Limiting | |
limit_req zone=reqlimit burst=20; # Max burst of request |
Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.
If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.
http://www.apple.com/osx/elcapitan-preview/
- split view - two apps side by side on full screen
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
<?php | |
// This is sample code to draw some of the charts I blogged about here: | |
// https://medium.com/ios-os-x-development/keeping-your-wits-as-an-indie-app-developer-3b5b14428e1f | |
// | |
// A few disclaimers: | |
// 1. This assumes you have at least 30 days of sales data in order to draw the Trailing 7 Days Chart | |
// 2. This assumes you have over 52 consecutive weeks of data in order to draw the Trailing Year Chart | |
// 3. I don't really know PHP. Everything this does, I had to look it up while writing it. If you actually know PHP, sorry. There are surely better ways. | |
// | |
// the results of this PHP script is intended to be drawn using the Flot library. |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs