Skip to content

Instantly share code, notes, and snippets.

🐍
Taming Python

Philipp Klaus pklaus

🐍
Taming Python
Block or report user

Report or block pklaus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pklaus
pklaus / create-lxc-container.sh
Created Jan 25, 2011
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>
@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 / clearRAM.sh
Last active Jul 10, 2019
A Script to Clear Cached RAM on Linux
View clearRAM.sh
#!/bin/bash
## Bash Script to clear cached memory on (Ubuntu/Debian) Linux
## By Philipp Klaus
## see <http://blog.philippklaus.de/2011/02/clear-cached-memory-on-ubuntu/>
if [ "$(whoami)" != "root" ]
then
echo "You have to run this script as Superuser!"
exit 1
fi
@pklaus
pklaus / server.py
Created Jul 30, 2014
TCP Server using socketserver in Python3
View server.py
#!/usr/bin/env python
# skeleton from http://kmkeen.com/socketserver/2009-04-03-13-45-57-003.html
import socketserver, subprocess, sys
from threading import Thread
from pprint import pprint
import json
my_unix_command = ['bc']
@pklaus
pklaus / lspci.txt
Created Jul 5, 2019
`sudo lspci -vv` for an Intel X550-T2 (operated at PCIe 2.0 x4 instead of PCIe 3.0 x4)
View lspci.txt
05:00.1 Ethernet controller: Intel Corporation Ethernet Controller 10G X550T (rev 01)
Subsystem: Intel Corporation Ethernet Converged Network Adapter X550-T2
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 16
Region 0: Memory at f0000000 (64-bit, prefetchable) [size=2M]
Region 4: Memory at f0400000 (64-bit, prefetchable) [size=16K]
Expansion ROM at df280000 [disabled] [size=512K]
Capabilities: [40] Power Management version 3
@pklaus
pklaus / ping.py
Created Mar 5, 2011
A pure python ping implementation using raw socket.
View ping.py
#!/usr/bin/env python2
"""
Other Repositories of python-ping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* https://github.com/l4m3rx/python-ping supports Python2 and Python3
* https://bitbucket.org/delroth/python-ping
@pklaus
pklaus / plotSmart.py
Last active Jul 1, 2019
S.M.A.R.T. to DB – A Python tool to store your HDD's SMART values in an SQLite database.
View plotSmart.py
#!/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 / arbitrary-waveform-test.py
Created May 4, 2012
Controlling the Rigol DG1022 with Python on Linux (using the usbtmc driver) – Proof of Concept
View arbitrary-waveform-test.py
#!/usr/bin/env python2
import usbtmc
import time
from math import sin
listOfDevices = usbtmc.getDeviceList()
dn = listOfDevices[0]
d = usbtmc.UsbTmcDriver(dn)
print d.getName()
@pklaus
pklaus / arduino-due_high-speed-ADC.ino
Last active Jun 26, 2019
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
@pklaus
pklaus / analyze-webcam.py
Created Jul 11, 2014
Motion detection using a webcam, Python, OpenCV and Differential Images
View analyze-webcam.py
#!/usr/bin/env python
"""
Found on
http://www.steinm.com/blog/motion-detection-webcam-python-opencv-differential-images/
"""
import cv2
def diffImg(t0, t1, t2):
You can’t perform that action at this time.