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 / clearRAM.sh
Last active January 8, 2024 08:00
A Script to Clear Cached RAM on Linux
#!/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 / ping.py
Created March 5, 2011 09:50
A pure python ping implementation using raw socket.
#!/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 / 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 / dnsupdate.py
Last active November 14, 2023 23:50
dnsupdate is meant to replace nsupdate, the standard DDNS update tool created by BIND authors ISC. While nsupdate does the job it is awkward to wrap in scripts and its usage in general is just not very intuitive. dnsupdate is meant to work well from the command line or from scripts and easy to use. It also does some nice things like automaticall…
#!/usr/bin/env python2.7
# Matt's DNS management tool
# Manage DNS using DDNS features
#
# See http://planetfoo.org/blog/archive/2012/01/24/a-better-nsupdate/
#
# Usage: dnsupdate -s server -k key -t ttl add _minecraft._tcp.mc.example.com SRV 0 0 25566 mc.example.com.
# -h HELP!
# -s the server
# -k the key
@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)
#!/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 / arduino-due_high-speed-ADC.ino
Last active October 4, 2023 02:20
Arduino Due: ADC → DMA → USB @ 1MSPS
#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 / create-lxc-container.sh
Created January 25, 2011 01:08
Automates the steps to set up LXC containers with virtualized environments on Ubuntu Linux
#!/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 / brother_ql - Related and Unrelated Software.md
Last active August 21, 2023 11:38
brother_ql - Related and Unrelated Software
@pklaus
pklaus / server.py
Created July 30, 2014 07:51
TCP Server using socketserver in Python3
#!/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 / create_keys_for_client.sh
Created May 2, 2011 22:06
Automation for client files creation on OpenVPN setup
#!/bin/bash
# <http://blog.philippklaus.de/2010/09/openvpn/>
set -x
#SERVERNAME=$(hostname)
SERVERNAME=$(ifconfig | grep -A 5 eth0 | grep -w 'inet addr' | tr '\t' ' ' | cut -d ':' -f 2 | cut -d ' ' -f 1)
read -e -p "Please enter the server you want your clients to connect to [default: $SERVERNAME]: " input
SERVERNAME="${input:-$SERVERNAME}"