This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdatomic.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
#include <string.h> | |
typedef struct { | |
void *data; | |
atomic_int head, tail, num_entries, size; | |
} ring_buffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"type":"basics", | |
"sections": [ | |
{ | |
"identity": | |
[ | |
{ | |
"type": "drivers_license", | |
"first_name": "Corné", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"header": "yo", | |
"body": "boo", | |
"date": "2018-11-21T10:14:13+00:00", | |
"state": "verified", | |
"image_name": "" | |
}, | |
{ | |
"header": "wow", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// infix flatMap operator - copied verbatim from http://www.objc.io/blog/2014/10/27/functional-snippet-4-flattening-and-mapping-arrays/ | |
infix operator >>= {} | |
func >>=<A, B>(xs: [A], f: A -> [B]) -> [B] { | |
return xs.map(f).reduce([], combine: +) | |
} | |
// decomposes array xs into a tuple containing the first element and the rest of the array. copied and edited from http://www.objc.io/blog/2014/10/06/functional-snippet-1-decomposing-arrays/ | |
func decompose<T>(xs: [T]) -> (T, [T])? { | |
return xs.count > 0 ? (xs[0], Array(xs[1..<xs.count])) : nil |