Skip to content

Instantly share code, notes, and snippets.

View tfeldmann's full-sized avatar
🐧
computer says no

Thomas Feldmann tfeldmann

🐧
computer says no
View GitHub Profile
@tfeldmann
tfeldmann / PDF-Extract.bat
Created May 29, 2012 12:43
PDF Extract - Extracts all PDF from a given Location while preserving the filetree (DKM)
:: Einstellungen
SET FOLDER_ROOT="..\CAD-DATEN"
SET FOLDER_CAD="CAD PDF"
SET FOLDER_PRODUCT="Produkt PDF"
SET PRODUCT_EXCLUDE_PREFIX=W-
:: ----------------------------------------------------------------------------------------------
:: | DO NOT TOUCH THE CODE BEHIND THIS LINE |
:: ----------------------------------------------------------------------------------------------
@tfeldmann
tfeldmann / c-statemachine.c
Last active October 6, 2015 18:08
C - Statemachine
/**
* Erweiterte C-Statemachine
* Das Programm gibt folgendes aus:
*
* BEGIN: Es geht los. Ich initialisiere das Ganze.
* BEGIN: Es geht weiter in den Zustand ADDITION_SMALL
* BEGIN: Auf Wiedersehen!
* ADDITION_SMALL: Ich fange erst einmal mit kleinen Zahlen an.
* ADDITION_SMALL: Addiere Eins...
* ADDITION_SMALL: Addiere Eins...
@tfeldmann
tfeldmann / circle_intersections.pde
Last active October 13, 2015 09:28
Find circle intersection points
PVector[] circleIntersections(PVector p1, float r1, PVector p2, float r2)
{
float d, a, h;
float dx, dy;
dx = p2.x - p1.x;
dy = p2.y - p1.y;
PVector dvect = new PVector(p1.x - p2.x, p1.y - p2.y);
d = dvect.mag();
import sys
import glob
import serial
def serial_ports():
"""Lists serial ports
:raises EnvironmentError:
On unsupported or unknown platforms
@tfeldmann
tfeldmann / face_recognition.py
Last active December 11, 2015 15:49
Face recognition in Python + OpenCV. I used Homebrew to install OpenCV, change your path to the haarcascade if needed.
import cv
HAAR_CASCADE_PATH = "/usr/local/Cellar/opencv/2.4.3/share/OpenCV/" \
"haarcascades/haarcascade_frontalface_default.xml"
CAMERA_INDEX = 0
def detect_faces(image):
faces = []
detected = cv.HaarDetectObjects(image, cascade, storage, 1.2, 2,
cv.CV_HAAR_DO_CANNY_PRUNING, (100,100))
@tfeldmann
tfeldmann / i2c_scanner.ino
Created April 18, 2013 09:13
A I2C Scanner for Arduino
// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not known.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
import itertools
def lowpass(img):
"""
A simple pure python low pass (antialiasing) filter.
Applies a gaussian blur on a 2D list of floats.
"""
width = len(img[0])
height = len(img)
@tfeldmann
tfeldmann / vector.py
Created June 16, 2016 13:48
A fast, feature-rich and easy-to-use python 2D vector class based on complex numbers
""" A python 2D vector class based on complex numbers
"""
import cmath
class Vector(complex):
@classmethod
def fromPolar(cls, r, phi):
return cls(cmath.rect(r, phi))
@tfeldmann
tfeldmann / update.sh
Last active November 27, 2019 11:22
Update all pip packages, brew and brew casks (macOS) and backup a list of the installed software
#!/bin/sh
set -e
PIP=pip3
scriptdir=$(dirname "$0")
listsdir="$scriptdir/lists"
mkdir -p "$listsdir"
echo "Update all python packages..."
@tfeldmann
tfeldmann / duplicates.py
Last active May 26, 2024 03:18
Fast duplicate file finder written in python
#!/usr/bin/env python
"""
Fast duplicate file finder.
Usage: duplicates.py <folder> [<folder>...]
Based on https://stackoverflow.com/a/36113168/300783
Modified for Python3 with some small code improvements.
"""
import os
import sys