Skip to content

Instantly share code, notes, and snippets.

View jhedev's full-sized avatar

Joel Hermanns jhedev

View GitHub Profile
@jhedev
jhedev / MakeFile
Created December 1, 2013 13:06
Makefile for LaTeX presentation using Beamerclass. Used eps graphics are created from svg and xcf files.
SVG=$(patsubst graphics/%.svg, graphics/%.eps, $(wildcard graphics/*.svg))
XCF=$(patsubst graphics/%.xcf, graphics/%.eps, $(wildcard graphics/*.xcf))
all: presentation
presentation: graphics
latex slides.tex
latex slides.tex
dvips slides.dvi
ps2pdf slides.ps
#!/bin/bash
sudo vpnc --gateway vpn.rwth-aachen.de --id FullTunnel --username ab123456
@jhedev
jhedev / Footline
Created December 11, 2013 22:31
Shows how to add frame numbers in footline in LaTeX Beamer class
\setbeamertemplate{footline}{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.6\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshorttitle\hspace*{3em}
\insertframenumber{} \hspace*{1ex}
\end{beamercolorbox}}%
# Taken from https://github.com/HIPERFIT/L0Language/blob/master/git-hooks/pre-commit
fail() {
echo "Aborting commit due to verification errors."
echo "If you disagree, use git commit --no-verify."
exit 1
}
hlintable() {
! egrep -q '{-# LANGUAGE.*QuasiQuotes' $1
@jhedev
jhedev / hash function
Last active August 29, 2015 14:01
Hash function in haskell
sum $ map (\(a,b) -> a*b `mod` 103) $ map (\(a,b) -> ((256^(7-a)) `mod` 103,b)) $ zip [1..] $ map (`mod` 103) $ map ord "string"
@jhedev
jhedev / unicode_print.py
Created May 29, 2014 14:14
Print fancy unicode characters
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
start = 0x0001F300
while start < 0x1F58E:
print(hex(start), chr(start))
start+=1
@jhedev
jhedev / primes
Created June 21, 2014 11:55
Python primes
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools
def gen(i):
while True:
yield i
i = i + 1
def primes(gen):
@jhedev
jhedev / keyboard_interrupt_decorator.py
Created July 9, 2014 09:18
Decorator to add a KeyboardInterrupt handler to a function
#!/usr/bin/env python3.3
# -*- coding: utf-8 -*-
import time
def interrupt_decorator(handler):
def decorator(fun):
def wrapper(*args, **kwargs):
try:
fun(*args, **kwargs)
@jhedev
jhedev / data.hs
Created January 9, 2015 18:40
Experimentations with conduit and data analysis (inspired by http://twdkz.wordpress.com/2013/05/31/data-analysis-with-monoids/)
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
import Control.Applicative
import Control.Monad.Trans.Resource
import Control.Monad.IO.Class
import qualified Data.ByteString.Char8 as BSC
import Data.Conduit
import qualified Data.Conduit.Combinators as C
import qualified Data.Conduit.List as CL
@jhedev
jhedev / problem4.hs
Created May 29, 2015 11:23
Problem4
problem4 :: [Int] -> Int
problem4 = read . foldl1 (++) . map show . sortBy f
f:: Int -> Int -> Ordering
f x y | v1 == v2 = EQ
| v1 < v2 = GT
| v1 > v2 = LT
where
v1 = concatInt x y
v2 = concatInt y x