Skip to content

Instantly share code, notes, and snippets.

View pklaus's full-sized avatar

Philipp Klaus pklaus

  • Frankfurt, Germany
View GitHub Profile
@KartikTalwar
KartikTalwar / Documentation.md
Last active December 9, 2023 16:53
Rsync over SSH - (40MB/s over 1GB NICs)
View Documentation.md

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@pklaus
pklaus / ddnsserver.py
Last active December 2, 2023 20:09 — forked from andreif/Simple DNS server (UDP and TCP) in Python using dnslib.py
Simple DNS server (UDP and TCP) in Python using dnslib.py
View ddnsserver.py
#!/usr/bin/env python
"""
LICENSE http://www.apache.org/licenses/LICENSE-2.0
"""
import argparse
import datetime
import sys
import time
import threading
@pklaus
pklaus / install-arch-linux-rpi-zero-w.sh
Last active November 26, 2023 18:58 — 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 / hist_to_pandas.py
Last active November 19, 2023 07:24
Read your Bash history into a Pandas DataFrame with this Python script.
View hist_to_pandas.py
#!/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 / tds-2012.py
Created March 3, 2010 12:44
Python plot display of Tektronix TDS-2012 Digital Sampling Oscilloscope (or other TDS-10xx or TDS-20xx DSO)
View tds-2012.py
#!/usr/bin/env python
# found on <http://www.febo.com/geekworks/data-capture/tds-2012.html>: <ftp://ftp.febo.com/pub/n8ur_programs/tds-2012.py>
# tds-2012.py
# version 0.1 -- 27 Jan 2004
#
# Plot display of Tektronix TDS-2012 (or other TDS-10xx or TDS-20xx DSO)
#
# Copyright 2004 by John R. Ackermann N8UR (jra@febo.com)
@pklaus
pklaus / enumerate_interfaces.py
Last active November 3, 2023 15:41
Python: List all Network Interfaces On Computer
View enumerate_interfaces.py
"""
Determine IPv4 addresses on a Linux machine via the socket interface.
Thanks @bubthegreat the changes to make it Py2/3 compatible and the helpful
code comments: https://gist.github.com/pklaus/289646#gistcomment-2396272
This version has all comments removed for brevity.
"""
import socket
import array
import struct
@pklaus
pklaus / rigol-plot.py
Last active October 25, 2023 18:21 — 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 / arduino-due_high-speed-ADC.ino
Last active October 4, 2023 02:20
Arduino Due: ADC → DMA → USB @ 1MSPS
View arduino-due_high-speed-ADC.ino
#undef HID_ENABLED
// Arduino Due ADC->DMA->USB 1MSPS
// by stimmer
// from http://forum.arduino.cc/index.php?topic=137635.msg1136315#msg1136315
// Input: Analog in A0
// Output: Raw stream of uint16_t in range 0-4095 on Native USB Serial/ACM
// on linux, to stop the OS cooking your data:
// stty -F /dev/ttyACM0 raw -iexten -echo -echoe -echok -echoctl -echoke -onlcr
@RobbieClarken
RobbieClarken / EPICS over Flask WebSockets.md
Last active September 23, 2023 20:19
EPICS over WebSockets with Flask
View EPICS over Flask WebSockets.md

Installation:

pip install Flask Flask-Sockets gunicorn pyepics

Deployment:

gunicorn -k flask_sockets.worker index:app
@pklaus
pklaus / create-lxc-container.sh
Created January 25, 2011 01:08
Automates the steps to set up LXC containers with virtualized environments on Ubuntu Linux
View create-lxc-container.sh
#!/bin/bash
### Bash Script that automates the steps to set up an LXC (Linux Container) boxed environment on Ubuntu Linux
### <http://blog.philippklaus.de/2011/01/container-virtualization-using-lxc-on-ubuntu/>
###
### More inspiration can be found in <https://github.com/phbaer/lxc-tools> and in
### <https://github.com/halcyon/lxc-tools/commit/b428a6973dd12b75c2400d41f60c454e752c10c6> and
### <http://mindref.blogspot.com/2011/01/debian-lxc-create.html>.
###
### Written by Philipp Klaus <philipp.l.klaus @ web.de>