Skip to content

Instantly share code, notes, and snippets.

View KingOfBrian's full-sized avatar

Brian King KingOfBrian

  • Boston Massachusetts
View GitHub Profile
import Foundation
final class Sample: NSObject {
@objc dynamic var name: String = ""
}
class MyObj: NSObject {
@objc dynamic var test: String = ""
}
extension NSObjectProtocol where Self: NSObject {
@AliSoftware
AliSoftware / GHDiff-HidePods.js
Last active February 13, 2017 11:40
Hide Pods/* related files in a GitHub diff page
// When you are in the diff page of a GitHub PR
// And want to hide all the Pods/* files in that diff page, use this:
// Paste that in your Web Inspector's console
var nodes = document.evaluate("//div[@class='file-header' and starts-with(@data-path,'Pods/')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );
for(i=0; i<nodes.snapshotLength; ++i) {
nodes.snapshotItem(i).parentNode.hidden = true
}
// Or even better, create a bookmark with this code for easy quick access:
@neilpa
neilpa / CStringArray.swift
Last active August 7, 2020 02:24
Swift wrappers for C functions taking char** arguments
// Usage
let argv = CStringArray(["ls", "/"])
posix_spawnp(nil, argv.pointers[0], nil, nil, argv.pointers, nil)
// Is this really the best way to extend the lifetime of C-style strings? The lifetime
// of those passed to the String.withCString closure are only guaranteed valid during
// that call. Tried cheating this by returning the same C string from the closure but it
// gets dealloc'd almost immediately after the closure returns. This isn't terrible when
// dealing with a small number of constant C strings since you can nest closures. But