Skip to content

Instantly share code, notes, and snippets.

View esmil's full-sized avatar

Emil Renner Berthing esmil

View GitHub Profile
@esmil
esmil / setpacking.md
Last active January 15, 2019 11:36
Set packing algorithm

I'm looking for an algorithm to "pack" a collection of sets as slices of a sequence. I'm sure somebody must have thought about this before. Specifically the algorithm has

Input: F_1, .., F_n where the F_i are finite subsets of some S

Output: A (shortest) sequence s_1, .., s_m in S such that for all i there is a j where F_i = { s_k | j <= k < j + |F_i| }

@esmil
esmil / keybase.md
Last active December 23, 2021 23:18
Keybase.io Identification

Keybase proof

I hereby claim:

  • I am esmil on github.
  • I am esmil (https://keybase.io/esmil) on keybase.
  • I have a public key whose fingerprint is 3D01 6226 97E2 5BCF EB70 B6EF 3A25 2495 7B40 60C8

To claim this, I am signing this object:

@esmil
esmil / rules
Last active August 2, 2016 15:02
#!/bin/bash
#
# Esmil's magic rules file
# - building Debian packages without insulting your intelligence since 2010
#
# See debian/build.sh for package specific build instructions.
# Here is a template for creating a new one:
#
# clean() {
# make clean
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM='verbose'
export GIT_PS1_SHOWCOLORHINTS=1
source /usr/share/git/git-prompt.sh
function prompt_command() {
[ -n "$DISPLAY" ] && echo -ne "\033]0;${PWD/$HOME/~}/ [$USER@$HOSTNAME]\a"
__git_ps1 '' '\[\033[01;32m\]\u\[\033[00m\]@\[\033[00;32m\]\h\[\033[01;34m\]\w\[\033[00m\]\$ ' '%s\\n'
@esmil
esmil / cmi.c
Created May 29, 2012 14:36
Experiments with GIO and DBus which ended in forth-like interpreter..
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
static GMainLoop *mainloop;
static GDBusConnection *bus;
static int exitcode = EXIT_FAILURE;
#define AGENT_PATH "/agent"
#define STACK_SIZE 20
@esmil
esmil / isprime.c
Created August 18, 2011 16:05
Fast deterministic primality test for 32bit numbers
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
/*
* returns a^e % n
*/
static unsigned int
powm(unsigned int a, unsigned int e, unsigned int n)
{
@esmil
esmil / atest.lua
Created March 12, 2011 16:19
Scary templating library..
local template = require 'template'
local html = template.new(function()
html{ xmlns = 'http://www.w3.org/1999/xhtml', lang = 'en', ['xml:lang'] = 'en',
head{
title 'Hathaway HTTP dump',
style{ type='text/css',
'th { text-align:left; }'
},
},
body{