Skip to content

Instantly share code, notes, and snippets.

Matthias Vallentin mavam

Block or report user

Report or block mavam

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sVimrc
let blacklists = ["*://www.inoreader.com/*", "*://mail.google.com/*"]
@mavam
mavam / flatbuffers-building.cpp
Created Mar 22, 2017
A function that takes a discriminated union and writes it into a flatbuffers builder.
View flatbuffers-building.cpp
flexbuffers::Builder& build(flexBuffers::Builder& builder, const data& x) {
struct converter {
converter(flatbuffers::FlatBufferBuilder& builder) : builder_{builder} {
}
using result_type = flatbuffers::Offset<detail::Data>;
result_type operator()(none) {
detail::DataBuilder db{builder_};
return db.Finish();
}
result_type operator()(boolean x) {
@mavam
mavam / flexbuffer-building.cpp
Created Mar 22, 2017
A function that takes a discriminated union and writes it into a flexbuffer builder.
View flexbuffer-building.cpp
flexbuffers::Builder& build(flexbuffers::Builder& builder, const data& x) {
static auto to_uint = [](auto i) {
return static_cast<std::underlying_type_t<detail::DataType>>(i);
};
struct converter {
converter(flexbuffers::Builder& builder) : builder_{builder} {
}
void operator()(none) {
builder_.UInt(to_uint(detail::DataType::NoneType));
}
@mavam
mavam / flexbuffer-serializer.cpp
Last active Mar 22, 2017
FlexBuffer serializer
View flexbuffer-serializer.cpp
#ifndef VAST_FLEXBUFFER_PACKER_HPP
#define VAST_FLEXBUFFER_PACKER_HPP
#include <caf/deserializer.hpp>
#include <caf/serializer.hpp>
#include <flatbuffers/flexbuffers.h>
#include "vast/chunk.hpp"
@mavam
mavam / aoc-day10-2.cpp
Created Mar 2, 2017
Advent of Code - Day 10 - Part Two
View aoc-day10-2.cpp
#include <cassert>
#include <iostream>
#include <vector>
#include <caf/all.hpp>
using namespace std;
using namespace caf;
// The same bot from part one.
@mavam
mavam / aoc-day10-1.cpp
Created Mar 2, 2017
Advent of Code - Day 10 - Part One
View aoc-day10-1.cpp
#include <cassert>
#include <iostream>
#include <vector>
#include <caf/all.hpp>
using namespace std;
using namespace caf;
// Predicate to check whether a particular bot is the puzzle solution.
@mavam
mavam / broker-synopsis.cpp
Last active May 6, 2016
Broker API Synopsis
View broker-synopsis.cpp
// --- component setup --------------------------------------------------------
// Creates a broker execution context that encapsulates runtime state, such as
// a thread pool and message type information.
system sys{cfg};
// Create a broker in a given system. A broker is a thin abstraction on top of
// a CAF actor for sending and receiving messages. There exist synchronous and
// aysnchronous brokers.
async_broker a{sys};
@mavam
mavam / ca-data-breaches.R
Last active Apr 26, 2016
California data breach analysis
View ca-data-breaches.R
# California data breach analysis
#
# Author: Matthias Vallentin <vallentin@icir.org>
# Copyright (c) 2016
#
# To reproduce, please contact me.
library(dplyr)
library(ggplot2)
library(lubridate)
@mavam
mavam / goes.R
Last active Aug 29, 2015
GOES-13 proton flux for particles >= 10 Mev
View goes.R
# Plots GOES-13 Proton Flux for particles >= 10 Mev.
#
# Data source: ftp://ftp.swpc.noaa.gov/pub/lists/particle/
#
# Check out http://stuffin.space to see where GOES-13 flies.
library(dplyr)
library(tidyr)
library(lubridate)
library(ggplot2)
@mavam
mavam / maildir-notifier
Last active Nov 9, 2017
A script which display new mails in Maildir directories as terminal-notifier messages
View maildir-notifier
#!/bin/sh
#
# Checks Maildir directories for new mail. For each new mail, it invokes
# terminal-notifier to show a notification with the message From and Subject
# header.
#
# The script can execute an arbitrary command when clicking on a notification,
# e.g., open mutt:
#
# % cat open-mutt
You can’t perform that action at this time.