Skip to content

Instantly share code, notes, and snippets.

Avatar

Niels van Hoorn nvh

View GitHub Profile
View 433MHz remote controller button signals
Button A
100000100011110000001110111100000000101111000010100000001001111000001011111110000010101111101000000000111111000001101111110000001011111000101110000010011111000000111111110000001010111010100000001001110000001011111110000010101111001011100000000110111000000111011111000000101010101100000010011111000000111111110000001010111010011110000001100111100000110101111000001010101011100000100111111000001111011110000010101110100111110000011000111100000001011111000000101010111100000001101111000000110111110000001010100001011110000000000111100000010101111000000010100111100000011000111000000101011111000000101000010101111000000001111110000001000111100000100001011110000000000111100000010101111000001010000101001111000000011111110000000001111100000000010111110000000001111100000001001111000000110000010001111000000111011111000000010111100000000101001111000000011111110000010001111100000100000000010111100000110111111000000101011110010000010001111000000111011110000000010111100001010000000100111100000001111111100000010101110100
View ProtocolInitializers Fix.swift
import Foundation
class Animal: NSObject {
}
protocol Named {
init(name: String)
}
protocol AnimalSpecification {
@nvh
nvh / buttonToggle.coffee
Created Jul 18, 2016 — forked from joshuacrowley/buttonToggle.coffee
Simple toggle button setup for Framer.js
View buttonToggle.coffee
for button in sketch.headerBttn.children
button.states.add
off:
opacity: 0.5
on:
opacity: 1
button.onTap (event, layer) ->
others = _.without(sketch.headerBttn.children, layer)
for other in others
other.states.switch("off")
@nvh
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
nvh / build-libevent-tvOS.sh
Created Nov 30, 2015
A build script for building a tvOS version for libevent
View build-libevent-tvOS.sh
#!/bin/bash
# Builds libevent for tvOS targets:
# AppleTVSimulator-x86_64, AppleTVOS-arm64.
#
# Copyright 2015 Niels van Hoorn <nvh@nvh.io>
#
# Based on work by Mike Tigas
# Copyright 2012 Mike Tigas <mike@tig.as>
#
# Based on work by Felix Schulze on 16.12.10.
@nvh
nvh / optionals.swift
Last active Aug 29, 2015
Test for optionals
View optionals.swift
extension Dictionary {
func test() {
for (key,value) in self {
//Works
if value is Int {
println("int")
}
//Throws compiler error: cannot downcast from 'Value' to a more optional type 'Int?'
if value is Int? {
println("optional int")
@nvh
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/TransIP.app/TransIP
Identifier: nl.transip.TransIP
Version: 2.2.1
Code Type: ARM (Native)
Parent Process: launchd [1]
@nvh
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
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 {
View example_root.js.coffee
class App.Root extends Spine.Stack
controllers:
resources: App.Resources
users: App.Users
routes:
'/resources' : 'resources'
'/users' : 'users'
default: 'users'
You can’t perform that action at this time.