Serve git smart HTTP repositories with uWSGI and nginx

Jan. 13, 2014, 11:17 a.m.     5 comments     Arch Linux    Software   

For some joint project of mine, I needed a way for them to access (clone, pull, push) the git repository that is hostet on my server without adding SSH accounts for them. With git 1.6.6 a feature called smart HTTP was introduced, which allows working with the repository via HTTP.

I set up the CGI script for smart HTTP git-http-backend using uWSGI and serve it (including basic authentication) via nginx. Let me show you how.

Read more...

One server monitoring solution to rule them all

Sept. 16, 2013, 3:30 p.m.     3 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.

Read more...

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}.