Skip to content

Instantly share code, notes, and snippets.

@kdungs
kdungs / .vimrc
Last active Jul 31, 2019
<50 line minimal Vim configuration.
View .vimrc
" .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
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/).
View expr.h
#pragma once
#include <string>
#include <utility>
struct Constant {
double value;
};
double eval(const Constant& c) { return c.value; }
@kdungs
kdungs / check.py
Last active Feb 21, 2016
Define a Check monad and corresponding functions in Python. Now also a repo: https://github.com/kdungs/python-mcheck
View check.py
""" 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
View strong_typedef_example.cc
#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)};
}
View agumon.go
package main
import (
zmq "github.com/pebbe/zmq4"
//"golang.org/x/net/websocket"
"errors"
"fmt"
"strconv"
"strings"
@kdungs
kdungs / Makefile
Created May 4, 2015
Code for blog post.
View Makefile
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 Aug 29, 2015
Code for my blog post on Higher Order Functions in C++.
View higherorder.cc
#include <cassert>
#include <functional>
//
// Classical Function Definition
//
int add(int x, int y) {
return x + y;
}
@kdungs
kdungs / hlt1muonflowcharts.py
Created Nov 28, 2014
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.
View hlt1muonflowcharts.py
#!/usr/bin/env python
import json
import TCKUtils.utils as ut
TCK = 0x6A1710
streamers = [
'Hlt1TrackMuonUnit',
'Hlt1DiMuonHighMassStreamer',
@kdungs
kdungs / Makefile
Created Jun 22, 2014
A Makefile for LaTeX with intermediate running of biber.
View Makefile
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}
View kalman_Makefile
CXX=clang++
CXXFLAGS=-std=c++11 -stdlib=libc++
CXXFLAGS+=-O3 -DNDEBUG
CXXFLAGS+=$(shell pkg-config --cflags eigen3)
all: kalman kalman_eigen
clean:
rm -f kalman
rm -f kalman_eigen