Skip to content

Instantly share code, notes, and snippets.

View pklaus's full-sized avatar

Philipp Klaus pklaus

  • Frankfurt, Germany
View GitHub Profile
@pklaus
pklaus / fetch-conference.py
Last active August 30, 2017 09:13
Downloading Slides from Indico
#!/usr/bin/env python
"""
Tool to download conference information from Indico
"""
import json, argparse, sys, re, logging, os, importlib
logger = logging.getLogger(__name__)
logging.basicConfig(format='%(levelname)s: %(message)s')
@pklaus
pklaus / fix-icalendar-time-offset.py
Last active September 30, 2015 14:53
Fix time in .ics files
#!/usr/bin/env python
"""
A script to shift times in a calendar (iCalendar / .ics) files
"""
from datetime import timedelta
import argparse, sys, os, logging
logger = logging.getLogger(__name__)
@pklaus
pklaus / scope.java
Last active September 19, 2015 20:41
Displaying waveforms of the DS1054Z oscilloscope with Processing
/*
A processing script to display waveforms
https://gist.github.com/pklaus/d16fcffe335ce520a0eb
*/
byte data[];
int a, b;
void setup()
{
@pklaus
pklaus / plot_gnuplot.py
Last active August 5, 2020 18:07
Plotting with gnuplot via Python
#!/usr/bin/env python
"""
This example shows how to call gnuplot from Python
It uses Popen() from the subprocess module.
The function run_gnuplot() takes care of it and returns the
resulting image as bytes. If you run this code on a web server,
the result could be returned to the client without storing
a file on the disk. In this example it is saved to a file in the end.
@pklaus
pklaus / allsatsabovehorizon.py
Last active February 8, 2024 19:24
plot of every tle.info satellite above your horizon once a second for 3 minutes (30x time lapse) (found on Reddit: https://www.reddit.com/r/dataisbeautiful/comments/3gxp87/i_just_plotted_every_tleinfo_satellite_above_my/)
#!/usr/bin/env python
import math
import time
from datetime import datetime
import ephem
import numpy as np
import matplotlib.pyplot as plt
import sys
import os.path
@pklaus
pklaus / analyze_jpnevulator_messages.py
Last active February 17, 2017 15:45
Analyze serial sniffing log files created with jpnevulator
#!/usr/bin/env python
"""
Analyze serial sniffing log files created with jpnevulator.
This tool is able to analyze log files created similar to this:
stty -F /dev/ttyUSB1 9600
stty -F /dev/ttyUSB2 9600
stty -F /dev/ttyUSB1
@pklaus
pklaus / scpi-server.py
Last active September 5, 2024 10:59
Run an SCPI Server implemented in Python
#!/usr/bin/env python
"""
Run a multi-threaded single-client SCPI Server implemented in Python.
Using a single-client server is sensible for many SCPI servers
where state would need to be shared between the multiple clients
and thus access to it would need to be made thread-safe.
In most cases, this doesn't make sense. Everything is
simply much easier when allowing only one client at a time.
@pklaus
pklaus / scpi_tcp.py
Last active May 22, 2021 02:34 — forked from GeoSpark/scpi_tcp.py
Python script to send commands to a Rigol scope (or any LXI/SCPI instrument) from first principles.
#!/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 / rpi2-arch-linux-to-sdcard.sh
Last active September 1, 2019 01:21
Raspberry Pi 2: Arch Linux ARM to SDcard Script. This is for the Rapsberry Pi 2. For the RPi 1, see https://gist.github.com/pklaus/b92dfc72136d1509c2ed
#!/bin/bash
# <http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2>
echo -e "\n\nArch Linux ARM to SD Card"
echo -e "for the Raspberry Pi 2"
echo -e "(and for the Raspberry Pi 3, if you don't need to use the unofficial arm64 variant)\n\n"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
@pklaus
pklaus / rigol-plot.py
Last active July 16, 2024 15:01 — 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.
#!/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.
"""