Skip to content

Instantly share code, notes, and snippets.

View Dev1an's full-sized avatar

Damiaan Dufaux Dev1an

View GitHub Profile
@Dev1an
Dev1an / simpleStructSyntax.swift
Created September 3, 2018 11:21
Create a simple struct node using SwiftSyntax
import SwiftSyntax
import Foundation
/// creates `struct Magic { let hat: Int }`
let magicStruct = SyntaxFactory.makeStructDecl(
attributes: nil,
modifiers: nil,
structKeyword: SyntaxFactory.makeStructKeyword(),
identifier: SyntaxFactory.makeIdentifier("Magic"),
genericParameterClause: nil,
@Dev1an
Dev1an / Evangelizo-Youversion.md
Last active August 19, 2018 08:05
Evangelizo cross referenced with Youversion bible book reference abbreviations.
Evangelizo Youversion Dutch description
1_Ch 1CH Uit het 1e boek der Kronieken
2_Ch 2CH Uit het 2e boek der Kronieken
1_Co 1CO Uit de 1e brief van de heilige apostel Paulus aan de christenen van Korinte
2_Co 2CO Uit de 2e brief van de heilige apostel Paulus aan de christenen van Korinte
1_Jn 1JN Uit de 1e brief van de apostel Johannes
2_Jn 2JN Uit de 2e brief van de heilige apostel Johannes
3_Jn 3JN Uit de 3e brief van de heilige apostel Johannes
1_M 1MA Uit het 1e boek der Makkabeeën
const spannerClassName = "non-nested-spanner"
const spannerQuerySelector = `.${spannerClassName}`
/**
*
* @param {Range} range
* @returns {?HTMLSpanElement}
*/
export function getContainingSpanner(range) {
let cursor = range.commonAncestorContainer
([CNIODarwin_mmsghdr]) $R2 = 9 values {
[0] = {
msg_hdr = {
msg_name = (_rawValue = 0x00000001036bf000)
msg_namelen = 16
msg_iov = 0x000000010183f000
msg_iovlen = 1
msg_control = nil
msg_controllen = 0
msg_flags = 0
//
// SmartValueTransformer.swift
// Panasonic IP setup
//
// Created by Damiaan on 12/04/18.
// Copyright © 2018 Devian. All rights reserved.
//
import Foundation
//
// SmartValueTransformer.swift
// Panasonic IP setup
//
// Created by Damiaan on 12/04/18.
// Copyright © 2018 Devian. All rights reserved.
//
import Foundation

Keybase proof

I hereby claim:

  • I am dev1an on github.
  • I am dev1an (https://keybase.io/dev1an) on keybase.
  • I have a public key ASAfYYEU3qZuXxduwzUsO2t3MyjczjlXueGxOxpafEd1Fwo

To claim this, I am signing this object:

@Dev1an
Dev1an / NioUDP.swift
Last active May 23, 2018 09:38
NIO UDP echo server.swift
import Foundation
import NIO
final class Echo: ChannelInboundHandler {
typealias InboundIn = AddressedEnvelope<ByteBuffer>
typealias OutboundOut = AddressedEnvelope<ByteBuffer>
static let response = "You sent: ".data(using: .utf8)!
func channelRead(ctx: ChannelHandlerContext, data: NIOAny) {
@Dev1an
Dev1an / LatinWords
Last active March 6, 2018 10:06
latin words numbered in base 6
1111111 A1
1111112 a2
1111113 a3
1111114 Aaron
1111115 ab
1111116 Aba
1111121 Ababus
1111122 abactor
1111123 abactus1
1111124 abactus2
@Dev1an
Dev1an / when.swift
Created January 4, 2018 23:06
The when expression is like Swift's if statement but it returns a value.
public struct WhenExpression<T> {
let successClosure: (()->T)?
public func `else`(failClosure: @escaping ()->T) -> T {
// failClosure actually never escapes the function but the compiler forces me to annotate it with @escaping
return (successClosure ?? failClosure)()
}
}
public func when<T>(_ condition: Bool, successClosure: @escaping ()->T) -> WhenExpression<T> {
return WhenExpression(successClosure: condition ? successClosure : nil)