Skip to content

Instantly share code, notes, and snippets.


Niels van Hoorn nvh

View GitHub Profile
View 433MHz remote controller button signals
Button A
View ProtocolInitializers Fix.swift
import Foundation
class Animal: NSObject {
protocol Named {
init(name: String)
protocol AnimalSpecification {
nvh /
Created Jul 18, 2016 — forked from joshuacrowley/
Simple toggle button setup for Framer.js
for button in sketch.headerBttn.children
opacity: 0.5
opacity: 1
button.onTap (event, layer) ->
others = _.without(sketch.headerBttn.children, layer)
for other in others
nvh / SynchronizedValueContaining.swift
Created Feb 2, 2016
An example how to have a synchronised property in a protocol-oriented way
View SynchronizedValueContaining.swift
public protocol SynchronizedValueContaining: class {
typealias SynchronizedValueType
var _valueAccessorSerialQueue: dispatch_queue_t { get }
var _privateValue: SynchronizedValueType { get set }
public extension SynchronizedValueContaining {
var synchronizedValue: SynchronizedValueType {
get {
var v: SynchronizedValueType!
nvh /
Created Nov 30, 2015
A build script for building a tvOS version for libevent
# Builds libevent for tvOS targets:
# AppleTVSimulator-x86_64, AppleTVOS-arm64.
# Copyright 2015 Niels van Hoorn <>
# Based on work by Mike Tigas
# Copyright 2012 Mike Tigas <>
# Based on work by Felix Schulze on 16.12.10.
nvh / optionals.swift
Last active Aug 29, 2015
Test for optionals
View optionals.swift
extension Dictionary {
func test() {
for (key,value) in self {
if value is Int {
//Throws compiler error: cannot downcast from 'Value' to a more optional type 'Int?'
if value is Int? {
println("optional int")
nvh / log.crash
Created Mar 12, 2015
TransIP iOS crashlog
View log.crash
{"app_name":"TransIP","app_version":"","bundleID":"nl.transip.TransIP","adam_id":325181784,"os_version":"iPhone OS 8.1.3 (12B466)","slice_uuid":"0d9c547d-3c8d-3eb0-b948-c1b5b26f47de","share_with_app_devs":true,"build_version":"2.2.1","is_first_party":false,"bug_type":"109","name":"TransIP"}
Incident Identifier: 1688A02F-A828-4E9D-80E4-D2825E4AA86E
CrashReporter Key: a80feeff082bd894f4b469f6e473ccaa67072c82
Hardware Model: iPhone7,1
Process: TransIP [7660]
Path: /private/var/mobile/Containers/Bundle/Application/685D85BB-B84F-4BD7-ACC1-EE1245308744/
Identifier: nl.transip.TransIP
Version: 2.2.1
Code Type: ARM (Native)
Parent Process: launchd [1]
nvh / DataSourceState.swift
Last active Oct 28, 2017
Data loading state machine enum
View DataSourceState.swift
enum DataSourceState<D,E> {
case Empty
case Loading(Box<D?>)
case Ready(Box<D>)
case Error(Box<E>,Box<D?>)
func toLoading() -> DataSourceState {
switch self {
case .Ready(let oldData):
let value: D? = oldData.value
nvh / Examples.swift
Last active Aug 29, 2015
Functional JSON Parsing in Swift
View Examples.swift
//MARK: examples
extension JSONValue {
static func url(value: JSONType) -> JSONResult<NSURL> {
return cast(value).map({NSURL(string: $0)})
extension JSONValue {
class App.Root extends Spine.Stack
resources: App.Resources
users: App.Users
'/resources' : 'resources'
'/users' : 'users'
default: 'users'