Skip to content

Instantly share code, notes, and snippets.

View mavam's full-sized avatar

Matthias Vallentin mavam

View GitHub Profile
@mavam
mavam / tenzir-library-stats.json
Last active September 16, 2025 10:35
Tenzir Library Statistics. See https://github.com/tenzir/library for details.
{
"lastUpdated": "2025-09-16T10:35:21.077Z",
"summary": {
"totalPackages": 24,
"totalPipelines": 131,
"totalContexts": 18,
"averagePipelinesPerPackage": 5.46,
"averageContextsPerPackage": 0.75
},
"topPackages": [
@mavam
mavam / dark_save.R
Last active May 16, 2022 09:24
A ggsave wrapper to store both a light and dark themed version of a plot.
# Wraps ggsave to produce both light and dark themed plot using ggdark.
dark_save <- function(filename, plot, sep = "-", ...) {
require(tools)
require(ggdark)
base <- file_path_sans_ext(filename)
ext <- file_ext(filename)
base_light <- paste(base, "light", sep = "-")
base_dark <- paste(base, "dark", sep = "-")
filename_light <- paste(base_light, ext, sep = ".")
filename_dark <- paste(base_dark, ext, sep = ".")
@mavam
mavam / bro-customization.md
Last active July 27, 2020 02:14
Bro script-level customization points.

General

# Process packets despite bad checksums.
redef ignore_checksums = T;

File Analysis

This will change significantly with Bro 2.2 when we have the file analysis

@mavam
mavam / sVimrc
Created September 12, 2018 09:16
sVimrc
let blacklists = ["*://www.inoreader.com/*", "*://mail.google.com/*"]
@mavam
mavam / dns-lookup.bro
Created November 2, 2012 22:59
DNS lookup in Bro using the when statement
when (local result = lookup_addr("www.bro-ids.org"))
{
for (addr in result)
print addr;
}
@mavam
mavam / maildir-notifier
Last active November 9, 2017 16:37
A script which display new mails in Maildir directories as terminal-notifier messages
#!/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
@mavam
mavam / flatbuffers-building.cpp
Created March 22, 2017 20:57
A function that takes a discriminated union and writes it into a flatbuffers builder.
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-serializer.cpp
Last active March 22, 2017 20:55
FlexBuffer serializer
#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 / flexbuffer-building.cpp
Created March 22, 2017 20:54
A function that takes a discriminated union and writes it into a flexbuffer builder.
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 / aoc-day10-2.cpp
Created March 2, 2017 05:17
Advent of Code - Day 10 - Part Two
#include <cassert>
#include <iostream>
#include <vector>
#include <caf/all.hpp>
using namespace std;
using namespace caf;
// The same bot from part one.