Skip to content

Instantly share code, notes, and snippets.

View kdungs's full-sized avatar
🇦🇶
Nett hier. Aber waren Sie schon mal in Baden-Württemberg?

Kevin Dungs kdungs

🇦🇶
Nett hier. Aber waren Sie schon mal in Baden-Württemberg?
View GitHub Profile
@kdungs
kdungs / dither.py
Created December 28, 2023 21:55
Bayer dithering in Python. Useful for Playdate development...
#!/usr/bin/env python3
import argparse
import pathlib
import numpy as np
from PIL import Image
bayer2x2 = 1/4 * np.array([
[0, 2],
@kdungs
kdungs / .vimrc
Last active July 31, 2019 08:09
<50 line minimal Vim configuration.
" .vimrc
"
" Kevin Dungs <kevin@dun.gs>
" 2016-07-16
filetype plugin on
set enc=utf-8
" Defaults
@kdungs
kdungs / expr.h
Last active May 15, 2016 17:23
A minimalistic solution for the Expression Problem as presented by Eli Bendersky in [his blog](http://eli.thegreenplace.net/2016/the-expression-problem-and-its-solutions/).
#pragma once
#include <string>
#include <utility>
struct Constant {
double value;
};
double eval(const Constant& c) { return c.value; }
@kdungs
kdungs / check.py
Last active February 21, 2016 12:42
Define a Check monad and corresponding functions in Python. Now also a repo: https://github.com/kdungs/python-mcheck
""" Define a Check monad and corresponding functions.
"""
from functools import partial
class Check:
""" This super class is not really necessary but helps make the structure
clear.
data Check a = Pass a | Fail Message
#include <iostream>
#include <boost/serialization/strong_typedef.hpp>
BOOST_STRONG_TYPEDEF(double, Time)
BOOST_STRONG_TYPEDEF(double, Distance)
BOOST_STRONG_TYPEDEF(double, Velocity)
Velocity calculateVelocity(Distance d, Time t) {
return Velocity{static_cast<double>(d) / static_cast<double>(t)};
}
package main
import (
zmq "github.com/pebbe/zmq4"
//"golang.org/x/net/websocket"
"errors"
"fmt"
"strconv"
"strings"
@kdungs
kdungs / Makefile
Created May 4, 2015 23:18
Code for blog post.
CXX=clang++
CXXFLAGS=-O3 -Werror -Weverything -pedantic -Wno-c++98-compat -std=c++14
all: test_mult
clean:
rm -f test_mult
@kdungs
kdungs / higherorder.cc
Last active August 29, 2015 14:19
Code for my blog post on Higher Order Functions in C++.
#include <cassert>
#include <functional>
//
// Classical Function Definition
//
int add(int x, int y) {
return x + y;
}
@kdungs
kdungs / hlt1muonflowcharts.py
Created November 28, 2014 08:57
Extract streamer information for LHCb HLT1 Muon Streamers from TCK. The resulting JSON is put into https://github.com/kdungs/lhcb-hltflow via the `--config` option.
#!/usr/bin/env python
import json
import TCKUtils.utils as ut
TCK = 0x6A1710
streamers = [
'Hlt1TrackMuonUnit',
'Hlt1DiMuonHighMassStreamer',
@kdungs
kdungs / Makefile
Created June 22, 2014 18:56
A Makefile for LaTeX with intermediate running of biber.
PROJECT=main
build/${PROJECT}.pdf: build/${PROJECT}.bbl
lualatex --output-directory=build ${PROJECT}
build/${PROJECT}.bbl: build/${PROJECT}.bcf
biber build/${PROJECT}
build/${PROJECT}.bcf: ${PROJECT}.tex
lualatex --output-directory=build ${PROJECT}