Skip to content

Instantly share code, notes, and snippets.

View lordi's full-sized avatar

Hannes Gräuler lordi

  • Osnabrück, Germany
View GitHub Profile
@lordi
lordi / tmuxselect
Last active May 29, 2019 21:29
tmux one-liner to show a menu of sessions to attach to
tmux list-sessions | awk -F: '{ print $1 " \"" $2 "\""; }' |\
xargs dialog --ok-label 'Attach' --cancel-label 'New session' --menu tmux 20 80 20 2>/tmp/tmux-session \
&& tmux attach-session -t $(cat /tmp/tmux-session; rm /tmp/tmux-session) \
|| tmux
@lordi
lordi / gist:d7c2969779500cc48b84
Created July 13, 2015 09:48
Flexible SRID/SRS GeometryField
from django.contrib.gis.db import models
class FlexibleSRSGeometryField(models.GeometryField):
"""
GeoDjango field that allows storing of geometries with different SRIDs.
"""
def __init__(self, *args, **kwargs):
kwargs['srid'] = -1
super(FlexibleSRSGeometryField, self).__init__(*args, **kwargs)
# It happens every so often on Arch Linux, that the kernel is updated and you have to reboot in order
# to being able to load the new kernel modules. This can lead to a situation where you are not able
# to mount filesystems, start docker, etc. because the old running kernel can not load the new modules.
# If you want to defer the reboot and still want to load some kernel modules, you can re-install the
# old kernel like this:
sudo pacman -U /var/cache/pacman/pkg/linux*-$(uname -r | grep -o "^.*-[0-9][0-9]*")-x86_64.pkg.tar.xz
Sometimes another client restricts the screen size of the current session.
The following command will quickly kill all other tmux clients from the session.
tmux list-clients -t $(tmux display-message -p '#S') -F '#{client_tty}' | grep -v $(tmux display-message -p '#{client_tty}') | xargs --max-args 1 tmux detach-client -t
Add it to ~/.tmux.conf to have it as "C-b k" shortcut:
bind k neww "tmux list-clients -t $(tmux display-message -p '#S') -F '#{client_tty}' | grep -v $(tmux display-message -p '#{client_tty}') | xargs --max-args 1 tmux detach-client -t"