Skip to content

Instantly share code, notes, and snippets.

View stlehmann's full-sized avatar
:bowtie:

Stefan Lehmann stlehmann

:bowtie:
View GitHub Profile
@stlehmann
stlehmann / sysvinit_template.sh
Created June 21, 2016 11:45
SysVinit Template
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@stlehmann
stlehmann / mkcdir.sh
Created June 21, 2016 07:42
Shell Script to create a directory and cd into it.
mkcdir () {
mkdir -p -- "$1" &&
cd -P -- "$1"
}
@stlehmann
stlehmann / markdownedit.py
Created June 20, 2016 18:49
Simple PyQt5 Widget for Markdown Editing and Preview
"""
markdownedit.py
copyright (c) 2014 by Stefan Lehmann, licensed under the MIT license
"""
import markdown2
from PyQt5.QtCore import QEvent
from PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import QWidget, QTextEdit, QVBoxLayout, \
@stlehmann
stlehmann / install_packages.py
Created April 27, 2016 12:50
Python3 Script for installing all wheels in the given directory to the given virtual environment. Target Platform: Windows
"""
Python3 Script for installing all wheels in the given directory to the given
virtual environment.
Target Platform: Windows
"""
VENV_PATH = 'venv'
WHEELS_PATH = 'required_packages'
@stlehmann
stlehmann / opencv_facedetection.py
Created November 18, 2015 18:10
frontal face detection with webcam
#!/usr/bin/env python
import os
import cv2
from PyQt5.QtWidgets import *
CASCADE_PATH = "/usr/local/share/OpenCV/haarcascades"
CASCADE_FILENAME = "haarcascade_frontalface_default.xml"
@stlehmann
stlehmann / addrmrows.py
Created October 31, 2015 17:25
Get row, count pairs where new items have been added / removed to the ordered list.
def add_rm_rows(old, new):
"""
Get row, count pairs where new items have been added / removed to the ordered list.
:old_list: list of items
:new_list: list of items
:return: list of [row, count] pairs where items have been added,
list of [row, count] pairs where items have been deleted
"""
@stlehmann
stlehmann / Python_Makefile
Last active August 30, 2015 09:11
Makefile for embedding Python in C
P=mycprogram
OBJECTS=mycprogram.c
CFLAGS=$(shell python3.4-config --cflags)
LDFLAGS=$(shell python3.4-config --ldflags)
LDLIBS=$(shell python3.4-config --libs)
CC=C99
$(P): $(OBJECTS)
clean:
@stlehmann
stlehmann / mathtextlabel.py
Created July 2, 2015 09:16
MathTextLabel for displaying math formulae in PyQt5 with matplotlib
from PyQt5.QtWidgets import QWidget
import matplotlib
matplotlib.use("Qt5agg")
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
import pylab
class MathTextLabel(QWidget):
def __init__(self, mathText, parent=None, **kwargs):
super().__init__(parent, **kwargs)
@stlehmann
stlehmann / setup.py
Last active September 21, 2018 12:06
Setup.py template with test command integration and version extraction
"""
Setup for Sensordb.
:author: Stefan Lehmann <stlm@posteo.de>
:license: MIT, see license file or https://opensource.org/licenses/MIT
:created on 2018-06-14 13:15:51
:last modified by: lehmann
:last modified time: 2018-06-14 13:21:47
@stlehmann
stlehmann / org.watson.ipython-notebook.plist
Created June 17, 2015 20:57
Launchctl Job definition for IPython Notebook
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>WorkingDirectory</key>
<!-- CHANGE THIS TO YOUR HOME DIRECTORY -->
<string>/Users/stefanlehmann</string>
<key>Label</key>