Skip to content

Instantly share code, notes, and snippets.

View monstermunchkin's full-sized avatar

Thomas Hipp monstermunchkin

View GitHub Profile

Keybase proof

I hereby claim:

  • I am monstermunchkin on github.
  • I am monstermunchkin (https://keybase.io/monstermunchkin) on keybase.
  • I have a public key ASC8CKvJTRkMx8pP45f5tXjb_-5k_xMjgBVxMjkhbqHwWAo

To claim this, I am signing this object:

@monstermunchkin
monstermunchkin / batnag.py
Last active December 20, 2015 11:19
Low battery warning with i3-nagbar
#!/usr/bin/env python
import signal
import subprocess
import time
import sys
test = False
@monstermunchkin
monstermunchkin / multimon.sh
Last active December 10, 2015 06:39
Multi-monitor setup depending on location. The location is determined by the ESSID.
#!/bin/bash -e
monsetup="$(xrandr)"
int_mon="$(grep -Eo 'LVDS[[:digit:]]' <<< "${monsetup}")"
ext_mon="$(grep -Eo 'VGA[[:digit:]]' <<< "${monsetup}")"
if grep -Eq 'VGA[[:digit:]] connected' <<< "${monsetup}"; then
# where am I?
at_work=0
for conn in $(sudo netcfg current); do
@monstermunchkin
monstermunchkin / mkrom.sh
Created August 8, 2012 11:44
Create rooted image from factory image
#!/bin/bash -e
factory_img='soju-jro03e-factory-c9f5a67d.tgz'
su_bin='su-bin-3.1.1-arm-signed.zip'
mkdir -pv ~/custom_rom
cd ~/custom_rom
wget -nc "https://dl.google.com/dl/android/aosp/${factory_img}"
@monstermunchkin
monstermunchkin / nofocusmm.sh
Created April 27, 2012 09:03
Sending keycodes to unfocused window (e.g. Spotify)
#!/bin/bash
KEY_NEXT=XF86AudioNext # keycode: 171
KEY_PLAY=XF86AudioPlay # keycode: 172
KEY_PREV=XF86AudioPrev # keycode: 173
# the window id of Spotify
SPOTIFY_WID=$(xdotool search --name "Spotify - Linux Preview")
if [[ -n ${SPOTIFY_WID} ]]; then
@monstermunchkin
monstermunchkin / cp_with_prog.py
Created April 15, 2012 10:14
Copy function with progress display in Python
#!/usr/bin/python
# Copy function with progress display using a callback function.
# The callback function used here mimics the output of
# 'rsync --progress'.
# Copyright (C) 2012 Thomas Hipp
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@monstermunchkin
monstermunchkin / suntab.py
Created January 6, 2012 23:24
Graph which shows sunrise and sunset times
# This program plots a graph with sunrises and sunsets.
#
# Copyright (C) 2012 Thomas Hipp
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
@monstermunchkin
monstermunchkin / xbmc_sets.py
Created August 5, 2011 20:47
Create .nfo file for movie sets in XBMC
#!/usr/bin/python3
# Copyright 2011 Thomas Hipp
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@monstermunchkin
monstermunchkin / SecureXMLRPCServer.py
Created July 22, 2011 19:29
SSL / TLS XML-RPC Server in Python
import socketserver
import ssl
import xmlrpc.server
try:
import fcntl
except ImportError:
fcntl = None
class SecureXMLRPCServer(socketserver.TCPServer,
xmlrpc.server.SimpleXMLRPCDispatcher):
@monstermunchkin
monstermunchkin / auex.sh
Created June 8, 2011 05:39
Extract audio and add tags for acc files.
#!/bin/bash
if ! [[ -f "$1" ]]; then
exit 1
fi
ftype=$(ffmpeg -i "$1" 2>&1 | grep -o 'Audio:[^,]*' | awk '{print $2}')
fflags='-vn -acodec copy'
case "$ftype" in