Navigation Menu

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 / 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}
@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
@kdungs
kdungs / candies_hps.py
Created May 19, 2013 13:54
Analysis of the relation between eaten candies and HP gain in "Candy box!" (http://candies.aniwey.net/).
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import linregress
# Set nice options for plots and use of LaTeX.
from matplotlib import rc
rc('text', usetex=True)
rc('font', family='serif')
@kdungs
kdungs / trAIn_template.lua
Created April 20, 2013 19:24
A basic template for a [trAInsported](http://trainsportedgame.no-ip.org/) AI containing the documentation.
--[[
Name:
Author:
Version:
Description:
]]--
--[[
This event is called, at the beginning of the round. The current map is
passed to it, so you can analize it, get it ready for pathfinding and search
@kdungs
kdungs / robot.js
Created December 19, 2012 13:41
Gauß 2.0
var Robot = function(robot) {
};
var found = false;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (!found) {
robot.rotateCannon(1);
robot.ahead(1);
@kdungs
kdungs / Makefile
Created November 28, 2012 21:18
Testing GSL
P = test_gsl
OBJECTS = test_gsl.c
CFLAGS = -g -Werror -O3 -std=gnu11 `pkg-config --cflags gsl`
LDLIBS = `pkg-config --libs gsl`
CC = gcc-mp-4.7
$(P): $(OBJECTS)
clean:
rm $(P)
@kdungs
kdungs / monty_hall.py
Created November 2, 2012 21:29
A simple simulation of the Monty Hall Problem.
#!/usr/bin/env python
# coding=utf-8
from __future__ import division
import itertools as it
import random as r
from sys import argv
def play_round(switch_choice=True):