Skip to content

Instantly share code, notes, and snippets.

View Dev1an's full-sized avatar

Damiaan Dufaux Dev1an

View GitHub Profile
@Dev1an
Dev1an / WAMP-URI-coding.js
Last active July 14, 2017 18:26
Decode/Encode WAMP URI's
function encode(string) {
return string.replace(/[\x20\x23\x25\x2e]/g, (character, offset) => "%" + string.charCodeAt(offset).toString(16))
}
function decode(string) {
return string.replace(/%(20|23|25|2e|2E)/g, (character, hex) => String.fromCharCode(parseInt(hex, 16)))
}
const Zyre = require('zyre.js')
const zreObserver = new Zyre()
zreObserver.start(function() {
console.log('connected')
zreObserver.join('visualisation')
})
zreObserver.on('join', (peerId, name, group) => {
@Dev1an
Dev1an / XALG-Converting.md
Last active September 3, 2017 17:46
xalg files converteren
  • Optie 1: Final Cut Pro X downloaden en daarmee de video openen. (📞 naar Michel voor licentie 💵)

  • Optie 2: Doen wat Thomas zegt: ffmpeg installeren en zijn script uitvoeren:

    • De volgende stappen loodsen je door het uitvoeren van scripts in de terminal. De grijs omkaderde tekststukken moeten geplakt worden in de terminal en bevatten geen “enter” tekens. Dus als je browser deze (omkaderde) tekst opgesplitst heeft in verschillende regels (gescheiden door “enter” tekens) dan doe je die (enter tekens) best eerst weg voor je ze in de terminal plakt.

    • Om ffmpeg te installeren heb je eerst HomeBrew nodig.

    • Homebrew installeren:

//: Playground - noun: a place where people can play
import Foundation
protocol MyProtocol {
var count: UInt {get}
mutating func increment()
}
struct MyStruct<T: MyProtocol>: MyGenericStructProtocol {
<div id="enter-page-box" style="background: rgba(250, 237, 216, 1); font-family: 'Alegreya Sans';text-align: center; cursor: pointer; width: 40em; padding: 1em; border: 1.5em solid rgba(28, 95, 131, 1)">
<header style="font-family: 'Alegreya SC'; padding: 1em; color: #25639E">
<h2 style="font-size: 2em; font-weight: 200">Welcome to the new website of the</h2>
<h1 style="font-size: 2em; font-weight: bold">Leuven Catholic English Speaking Community!</h1>
</header>
<section style="font-size: 1.3em">
<p style="margin: 1em 0">Our website is brand new! We’re bringing you a new look, a new domain, and a new adventure.</p>
<p style="margin: 1em 0">You may encounter a few bumps during your visit. If something doesn’t display correctly, look right, etc., please send a message to the webmaster, and we’ll get it fixed.</p>
<p style="margin: 1em 0">Thanks for your feedback, support, and patience as we continue to improve your online experience with our community!</p>
</section>
<div id="enter-page-box" style="background: rgba(250, 237, 216, 1); font-family: 'Alegreya Sans';text-align: center; cursor: pointer; width: 45em; padding: 1em; border: 1.5em solid rgba(28, 95, 131, 1)">
<header style="font-family: 'Alegreya SC'; padding: 1em; color: #25639E">
<h2 style="font-size: 1.6em; font-weight: 400">Welcome to the new website of the</h2>
<h1 style="font-size: 1.9em; font-weight: 400">Leuven Catholic English Speaking Community!</h1>
</header>
<section style="font-size: 1.3em">
<p style="margin: 1em 0">Our website is <span style="font-family: Alegreya Sans SC; font-style: italic;">brand new!</span> We’re bringing you a new look, a new domain, and a new adventure.</p>
<p style="margin: 1em 0">You may encounter a few bumps during your visit. If something doesn’t display correctly, look right, etc., please send a message to the webmaster, and we’ll get it fixed.</p>
<p style="margin: 1em 0">Thanks for your feedback, support, and patience as we continue to improve your online ex
@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)
@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 / 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) {

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: