Skip to content

Instantly share code, notes, and snippets.

View langthom's full-sized avatar

Thomas Lang langthom

  • Post-Doc at Fraunhofer EZRT
View GitHub Profile
@langthom
langthom / CTSieve.cc
Created October 5, 2017 16:02
A simple, and damn stupid compile-time Sieve of Erathostenes.
// A primitive compile-time Sieve of Erathostenes, (c) Thomas Lang, 2017
#include <iostream>
// First, the usual value-to-type wrapper for usage in type lists.
template<unsigned int V>
struct Value {
enum { value = V };
};
// And the ususal conditional.
@langthom
langthom / compileTimePrimeFactorization.cc
Created August 6, 2017 14:28
A simple compile time functionality for calculating the prime factorization of a number.
// Compile time prime factorization.
// (C) Thomas Lang, Aug 6th, 2017
#include <iostream>
// First, we create a basic list structure in a functional style:
struct NIL {
using Head = NIL;
using Tail = NIL;
};
# Using defer i.e. calling a function when leaving scope.
# Neat trick for cleanup of resources.
#
# Copyright of lines 5-27 to @briandfoy_perl
use v5.10.1;
use strict;
use warnings FATAL => "all";
sub defer {
my ($sub) = @_;
@langthom
langthom / crawlThem.pl
Created August 11, 2016 22:45
simple crawler for getting xkcd comics
#!/usr/bin/env perl
# A simple crawler for getting the nice comics from xkcd.com
#(c) Thomas Lang, 2016
#
# Yes, this is damn non-performant, but if it works, it ain't stupid.
use warnings;
use strict;
use LWP::Simple;
@langthom
langthom / gol.pl
Created July 27, 2016 13:08
Conway's "Game Of Life" in Perl
#!/usr/bin/perl
# A damn nice "Conway's game of life".
# Taken from 'Coding for fun with Python' and translated into Perl.
#
# Thomas Lang, (c) 2016.
use strict;
use warnings;
use OpenGL qw/ :all/;