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 / embedding_in_qt5.py
Last active March 24, 2023 07:56
Embedding Matplotlib Plots in PyQt5
#!/usr/bin/env python
# embedding_in_qt5.py --- Simple Qt4 application embedding matplotlib canvases
#
# Copyright (C) 2005 Florent Rougon
# 2006 Darren Dale
# with Updates from @boxcontrol
# <http://www.boxcontrol.net/embedding-matplotlib-plot-on-pyqt5-gui.html>
# <https://github.com/boxcontrol/matplotlibPyQt5>
#
@pklaus
pklaus / convert-pickle-version.py
Created July 2, 2015 09:52
A command line tool to convert between pickle protocol versions
#!/usr/bin/env python
import pickle
import argparse
import sys
def main():
parser = argparse.ArgumentParser(description='Convert between pickle protocol versions.')
parser.add_argument('input_file')
parser.add_argument('output_file')
@pklaus
pklaus / dmesg Desktop
Created June 3, 2015 06:58
CSL 300Mbps WiFi Adapter 2.4 and 5GHz / Ralink RT5572 on Linux
`dmesg` on Arch Linux (kernel 4.0.1-1-ARCH):
[ 503.182208] usb 2-1.5: new high-speed USB device number 5 using ehci-pci
[ 504.409809] usb 2-1.5: reset high-speed USB device number 5 using ehci-pci
[ 504.502643] ieee80211 phy1: rt2x00_set_rt: Info - RT chipset 5592, rev 0222 detected
[ 504.531452] ieee80211 phy1: rt2x00_set_rf: Info - RF chipset 000f detected
[ 504.531959] ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'
[ 504.532156] usbcore: registered new interface driver rt2800usb
[ 504.534330] rt2800usb 2-1.5:1.0 wlp0s29u1u5: renamed from wlan0
@pklaus
pklaus / realtimeplot.py
Last active February 19, 2020 21:03
Plotting or real-time data with the Matplotlib animation API. Source: http://stackoverflow.com/a/15724978/183995
#!/usr/bin/env python
import numpy as np
import time
import matplotlib
matplotlib.use('TKAgg')
#matplotlib.use('GTKAgg')
from matplotlib import pyplot as plt
@pklaus
pklaus / plotSmart.py
Last active February 28, 2024 01:46
S.M.A.R.T. to DB – A Python tool to store your HDD's SMART values in an SQLite database.
#!/usr/bin/env python
# -*- encoding: UTF8 -*-
""" read out S.M.A.R.T. values out of the database and plot them using matplotlib
<http://matplotlib.sourceforge.net/examples/pylab_examples/anscombe.html>
"""
from pylab import *
from os import geteuid
@pklaus
pklaus / hist_to_pandas.py
Last active November 19, 2023 07:24
Read your Bash history into a Pandas DataFrame with this Python script.
#!/usr/bin/env python
# -*- encoding: UTF8 -*-
""" Read all entered bash commands ('the history') into a Pandas dataframe
http://blog.philippklaus.de/2015/04/enhancing-and-enlarging-the-bash-history/
"""
import pandas as pd
import matplotlib.pyplot as plt
from IPython import embed
@pklaus
pklaus / hist_to_db.py
Last active December 23, 2021 16:39
Store your Bash history in an SQLite database with this Python script.
#!/usr/bin/env python
# -*- encoding: UTF8 -*-
""" Store all entered bash commands ('the history') in a database
http://blog.philippklaus.de/2015/04/enhancing-and-enlarging-the-bash-history/
"""
import sqlite3
from os import path, makedirs
import sys
@pklaus
pklaus / NMEA Output.md
Created March 10, 2015 16:00
u-blox 7 GPS/Glonass Receiver G-7020 / VK-172

output of the command

screen /dev/ttyACM0 38400

without any prior special settings:

$GPTXT,01,01,02,u-blox ag - www.u-blox.com*50
$GPTXT,01,01,02,HW  UBX-G70xx   00070000 *77
$GPTXT,01,01,02,ROM CORE 1.00 (59842) Jun 27 2012 17:43:52*59

$GPTXT,01,01,02,PROTVER 14.00*1E

@pklaus
pklaus / gerber2svg.py
Last active May 3, 2016 19:47
A tool to convert Gerber files to SVG. Uses pcb-tools.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Inspired by
# https://github.com/curtacircuitos/pcb-tools/blob/master/gerber/__main__.py
# Copyright 2013-2014 Paulo Henrique Silva <[email protected]>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@pklaus
pklaus / gerber_query.py
Last active August 29, 2015 14:15
Script to query Gerber file outer dimensions
#!/usr/bin/env python
# From <https://www.wayneandlayne.com/blog/2013/04/02/script-to-query-gerber-file-outer-dimensions/>
# Gerber query script
# Usage: ./gerber_query.py board_edges.gbr
# Written by Matthew Beckler for Wayne and Layne, LLC
# Based on a script from @laen
# Released into the Public Domain. Have fun
def main():