# Create scientific presentations with Inkscape, InkSlides and InkTex

Dec. 10, 2013, 4:22 p.m.     0 comments     Misc    Software

In this short article, I show you how to create nice scientific presentations using a combination of Inkscape and LaTex, made possible by two small tools I wrote.

# One server monitoring solution to rule them all

Sept. 16, 2013, 3:30 p.m.     0 comments     Python    Server

In our research group we have an old and a new fileserver, each having multiple LVM volumes of which some are backed up and some are not. Since we recently had several issues of somebody accidentally filling a partition completely (and, of course, being on vacation), I was looking into server monitoring software to get a simple overview about disk usages of our servers.

Now, all the stuff out there is either closed source or way too sophisticated for my use case. So I built my own monitoring application, which is arguably the simplest of all.

# script to cycle through pulseaudio sinks during playback

Aug. 22, 2013, 6:57 p.m.     0 comments     Python

I am currently giving pulseaudio another try, because alsa is not really flexible when it comes to multiple outputs. I usually bind a keyboard shortcut to cycle through audio output devices, in order to quickly switch between headphones and speakers etc.

Here is a python solution to do that with pulseaudio. It uses the cli tool pacmd which must be installed for the script to work. It just switches the default sink to the one after the current default and moves all sound inputs (i.e., the playback) to the new default.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #!/usr/bin/env python3 import subprocess as sp import re # This script cycles pulseaudio sinks and changes the defaults. # Audio playback is also moved to the new default sink. The script # is intended to bind to some keyboard shortcut to cycle through # outputs on the fly. # # Requirements: pacmd, python3 dev_out, _ = sp.Popen('pacmd list-sinks', shell=True, stdout=sp.PIPE).communicate() inp_out, _ = sp.Popen('pacmd list-sink-inputs', shell=True, stdout=sp.PIPE).communicate() devices = re.findall(r"(\*?) index: (\d+)", str(dev_out)) inputs = re.findall(r"index: (\d+)", str(inp_out)) # find the next default device, i.e., the one after the current default found = False next_device = devices[0][1] for d in devices: if found: next_device = d[1] break found = (d[0] == "*") # set default device and move inputs sp.call(["pacmd", "set-default-sink", next_device]) for i in inputs: sp.call(["pacmd", "move-sink-input", i, next_device]) 

# Showing references on a timeline in LaTeX

Aug. 7, 2013, 3:57 p.m.     0 comments     latex

This is a small script I made for visualizing biblatex references on a timeline. It uses biblatex and chronography.sty. The solution essentially comes from this texexchange question I posted earlier today.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \documentclass{scrartcl} \usepackage{chronology} \usepackage[landscape]{geometry} \usepackage[backend=biber]{biblatex} \addbibresource{refs.bib} \DeclareCiteCommand{\eventcite}{}{ \event{\thefield{year}}{ \printnames{labelname},\space\printfield{year} } }{}{} \begin{document} \begin{chronology}[5]{1960}{2013}{\textwidth} \eventcite{Milnor:Morse} \end{chronology} \end{document} 

The \eventcite command extracts the year from the bib entry and uses it as an argument for the \event command of chronography.sty. Now, you can add references to the timeline as simple as \eventcite{bibkey}.

# Split a string with custom delimiter in C++

Aug. 2, 2013, 1:57 p.m.     0 comments     C++

There are probably millions of solutions for this problem, but let me quickly paste my helper function for splitting std::strings with the C++ stdlib. I know, that boost::tokenize is perfect at this, however, using C++11, I am trying to avoid boost as a dependency in my software.

So here it is: Just pass it a string and the delimiter char, and you get back a vector with the tokens. Note, that empty tokens are not returned.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include #include #include std::vector split(const std::string &s, char delim) { std::vector elems; std::string item; // use stdlib to tokenize the string std::stringstream ss(s); while (std::getline(ss, item, delim)) if(!item.empty()) elems.push_back(item); return elems; } 

I hope it is useful for anybody. :)