Skip to content

Instantly share code, notes, and snippets.

View keybuk's full-sized avatar

Scott James Remnant keybuk

View GitHub Profile

Keybase proof

I hereby claim:

  • I am keybuk on github.
  • I am keybuk (https://keybase.io/keybuk) on keybase.
  • I have a public key whose fingerprint is 8D2D 1F62 A4AC 9A22 FEFC B0DC 21EC 4FDC 84AD 676C

To claim this, I am signing this object:

@ Discovering: 0x00 (6)
< HCI Command: LE Set Random Address (0x08|0x0005) plen 6 [hci0] 653.360430
Address: 29:C6:32:82:FB:DC (Non-Resolvable)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 653.361283
LE Set Random Address (0x08|0x0005) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7 [hci0] 653.361356
Type: Active (0x01)
Interval: 11.250 msec (0x0012)
Window: 11.250 msec (0x0012)
@keybuk
keybuk / swift-black-magic
Last active August 29, 2015 14:08
Sub-property Black Magic in Swift
First we set up a struct, a by-value type:
1> struct Point {
2. var x, y: Int
3. }
And we make an array of them:
4> var points = [Point]()
points: [(Point)] = 0 values
import UIKit
class ViewController: UIViewController, UICollectionViewDataSource {
@IBOutlet weak var collectionView: UICollectionView?
var data = [ "🍅", "🍍", "🍎" ]
override func viewDidLoad() {
super.viewDidLoad()
public enum Model: String {
case Company
case Team
case Employee
}
extension NSEntityDescription {
public class func entity(model: Model, inManagedObjectContext context: NSManagedObjectContext) -> NSEntityDescription {
// Since we know we always have a matching entity, we can just force-unwrap this.
return NSEntityDescription.entityForName(model.rawValue, inManagedObjectContext: context)!
@keybuk
keybuk / up-next.md
Last active October 22, 2015 22:21

Up Next

So here's how I think Music/iTunes works, and how I think iTunes handles the crazy-assed "Up Next" system and why it doesn't make sense to anyone.

When you press Play on any single track, that begins playing (duh). But also, Music/iTunes takes a look at the context in which you pressed Play, e.g. the alphabetical list of songs, whether you have Shuffle on, etc. and figures out what it might play next:

  • Now Playing:
    • Ain't Goin' to Goa
  • Playing Next:
@keybuk
keybuk / CastingMadness.swift
Created December 15, 2015 23:05
Experimenting with Swift protocols
var y = NSOrderedSet(orderedSet: my)
struct CastingGenerator<G: GeneratorType, T>: GeneratorType {
typealias Element = T
var base: G
init(_ base: G) {
self.base = base
func inSimulator() -> Bool { return TARGET_OS_SIMULATOR != 0 }
if inSimulator() {
// In simulator
} else {
// Not in simulator
}
@keybuk
keybuk / FetchedResults.swift
Last active March 15, 2016 04:22
FetchedResultsController WIP
//
// FetchedResults.swift
// DungeonMaster
//
// Created by Scott James Remnant on 3/14/16.
// Copyright © 2016 Scott James Remnant. All rights reserved.
//
import CoreData
import Foundation
@keybuk
keybuk / withable.swift
Created March 24, 2016 20:30
Withable
struct Person {
var firstName, lastName: String
}
let john = Person(firstName: "John", lastName: "Doe")
protocol Withable {
func with(changes: (inout Self) -> Void) -> Self