Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
Taming Python

Philipp Klaus pklaus

🐍
Taming Python
View GitHub Profile
@pklaus
pklaus / ddnsserver.py Simple DNS server (UDP and TCP) in Python using dnslib.py
View ddnsserver.py
#!/usr/bin/env python
# coding=utf-8
import argparse
import datetime
import sys
import time
import threading
import traceback
import socketserver
@pklaus
pklaus / get_name.py
Last active Jul 22, 2020 — forked from starrhorne/gist:1637310
Extracting font names from TTF/OTF files using Python and fontTools
View get_name.py
#!/usr/bin/env python
"""
From
https://github.com/gddc/ttfquery/blob/master/ttfquery/describe.py
and
http://www.starrhorne.com/2012/01/18/how-to-extract-font-names-from-ttf-files-using-python-and-our-old-friend-the-command-line.html
ported to Python 3
"""
@pklaus
pklaus / rigol-plot.py
Last active Feb 23, 2020 — forked from shirriff/rigol-plot.py
Example of controlling a Rigol oscilloscope via Python. Fetch a 1 MB "Long Memory" trace from the oscilloscope and graph it using matplotlib.
View rigol-plot.py
#!/usr/bin/env python
"""
Download data from a Rigol DS1052E oscilloscope and graph with matplotlib.
By Ken Shirriff, http://righto.com/rigol
Based on http://www.cibomahto.com/2010/04/controlling-a-rigol-oscilloscope-using-linux-and-python/
by Cibo Mahto.
"""
@pklaus
pklaus / scpi_tcp.py
Last active Feb 19, 2020 — forked from GeoSpark/scpi_tcp.py
Python script to send commands to a Rigol scope (or any LXI/SCPI instrument) from first principles.
View scpi_tcp.py
#!/usr/bin/env python
"""
Zeroconf Discovery for Rigol DS1000Z-series scopes
--------------------------------------------------
Documentation worth looking at:
* http://lxistandard.org/Documents/Specifications/LXI%20Device%20Specification%202011%20rev%201.4.pdf
* http://lxistandard.org/GuidesForUsingLXI/Introducing%20LXI%20To%20Your%20Network%20Administrator%20May%2024_2013.pdf
* http://lxistandard.org/GuidesForUsingLXI/LXI_Getting_Started_Guide_May_1_2013.pdf
@pklaus
pklaus / numba-diffusion.py
Last active Feb 5, 2020 — forked from quasiben/numba-diffusion.py
Diffusion with Sink using Python and Numba
View numba-diffusion.py
import numpy as np
from numba.decorators import jit
from numba import *
import time
mu = 0.1
Lx, Ly = 601, 601
@jit('void(double[:,:], double[:,:], int32)')
def diffusionObstacleStep(u, tempU, iterNum):
@pklaus
pklaus / sphinx_to_github.sh
Created Jul 11, 2012 — forked from brantfaircloth/sphinx_to_github.sh
Sphinx documentation to github gh-pages without submodules
View sphinx_to_github.sh
# assume the following directory structure where contents of doc/
# and source/ are already checked into repo., with the exception
# of the _build directory (i,e. you can check in _themes or _sources
# or whatever else).
#
# proj/
# source/
# doc/
# remove doc/_build/html if present
@pklaus
pklaus / run_docker_x11.sh
Last active May 13, 2019 — forked from slok/run_docker_x11.sh
x11 with docker archlinux
View run_docker_x11.sh
#!/bin/bash
KEY=$(xauth list | grep "$(hostname)/unix:0" | awk '{ print $3 }' | head -n 1)
CONT_HOSTNAME=docker-skype
xauth add $CONT_HOSTNAME/unix:0 . $KEY
docker run -it --rm -v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/.Xauthority:/tmp/.Xauthority \
-v /dev/snd:/dev/snd \
-e DISPLAY=unix$DISPLAY \
@pklaus
pklaus / bottle-server.py
Last active Jan 12, 2019 — forked from anjackson/gist:2888380
Mounting a proxy server to a /path of a Bottle app
View bottle-server.py
import bottle
from hacks import ProxyServer
root = bottle.Bottle()
ps = ProxyServer()
root.mount(ps.wrapped_proxy_app, "/proxyapp")
@root.route('/hello/:name')
@pklaus
pklaus / install-arch-linux-rpi-zero-w.sh
Last active Sep 28, 2018 — forked from larsch/install-arch-linux-rpi-zero-w.sh
Install Arch Linux ARM for Raspberry Pi Zero W on SD Card (with commands to configure WiFi before first boot).
View install-arch-linux-rpi-zero-w.sh
#!/bin/sh -exu
dev=$1
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
}
# RPi1/Zero (armv6h):
@pklaus
pklaus / print-png-label-to-networked-brother-label-printer.sh Bash function to print black and white PNG (and JPEG, GIF, BMP) files to a networked Brother label printer (such as the QL-720NW)
View print-png-label-to-networked-brother-label-printer.sh
# Print a black and white PNG file on the first available Brother label printer
# Requires https://github.com/pklaus/brother_ql
# Source (.) this file to set bash completion and add the print function.
function print-png-label() {
if [ -f "$1" ]; then
# Change these to match your printer:
local LBLPMODEL="QL-720NW"
local LBLPSIZE="62"
You can’t perform that action at this time.