Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mstaflex on github.
  • I am mstaflex (https://keybase.io/mstaflex) on keybase.
  • I have a public key ASDcgQWZU8JcRMI7g4BGDIzIdb5KCRJ1WBSszNWuvrlwMwo

To claim this, I am signing this object:

@mstaflex
mstaflex / StepMotorOscillator.c
Created February 10, 2016 15:05
C program that lets a connected stepper motor swing back and forth through a run-time defined angle with a run-time defined speed
#define N_EN PORTB.f2
#define TRIS_N_EN TRISB.f2
#define MS1 PORTB.f1
#define TRIS_MS1 TRISB.f1
#define MS2 PORTB.f0
#define TRIS_MS2 TRISB.f0
#define MS3 PORTA.f5
@mstaflex
mstaflex / rc.local
Created April 30, 2015 14:25
Setting up simple execution environment with tmux and rc.local
# executing a script for user 'pi' with std. shell
su -c "./home/pi/run_robbi_demo.sh" -s /bin/sh pi
@mstaflex
mstaflex / Tornado webserver MJPEG streamer
Created November 24, 2014 11:23
Python Tornado webserver that streams JPEGs (in img/) as MJPEG-Stream using asynchronous timed callbacks (yields), being able to handly many different streams at the same time
import tornado.ioloop
import tornado.web
import gen
import time
import os
import tornado
file_list = os.listdir("img")
counter = 0
This file has been truncated, but you can view the full file.
# DO NOT CHANGE: FILE-FORMAT DEFINITION-DATE = 2008-11-16 $
# $
# nam_dict.txt $
# ------------ $
# $
# List of first names and gender. $
# $
# Copyright (c): $
# 2007-2008: Jörg MICHAEL, Adalbert-Stifter-Str. 11, $
# 30655 Hannover, Germany $
@mstaflex
mstaflex / name_filter.py
Last active August 29, 2015 14:07
Gist to select names from a database file according to a regex scheme and a country. Mainly for games like "my daughter will be called a name with an a and an u" :P The database file can be found here https://gist.github.com/mstaflex/161edf0c61a764a3345f
import re
EAST_WEST_BORDER_COLUMN = 44
REGEX_COMPILED = p = re.compile('([\w]*n[\w]*u[\w]*)|[\w]*u[\w]*n[\w]*')
input_file_data_base = "nam_dict.txt"
output_file_filtered = "name_database_filtered.txt"
output_file = "possible_names_selection.txt"
country_column = {30: "Great Britain", 31: "Ireland", 32: "U.S.A.", 33: "Italy", 34: "Malta", 35: "Portugal", 36: "Spain", 37: "France", 38: "Belgium", 39: "Luxembourg", 40: "the Netherlands", 41: "East Frisia", 42: "Germany", 43: "Austria", 44: "Swiss", 45: "Iceland", 46: "Denmark", 47: "Norway", 48: "Sweden", 49: "Finland", 50: "Estonia", 51: "Latvia", 52: "Lithuania", 53: "Poland", 54: "Czech Republic", 55: "Slovakia", 56: "Hungary", 57: "Romania", 58: "Bulgaria", 59: "Bosnia and Herzegovina", 60: "Croatia", 61: "Kosovo", 62: "Macedonia", 63: "Montenegro", 64: "Serbia", 65: "Slovenia", 66: "Albania", 67: "Greece", 68: "Russia", 69: "Belarus", 70: "Moldova", 71: "Ukraine", 72: "Armenia", 73: "Azerbaijan", 74: "Georgia", 75: "Kazakhstan/Uzbekistan,etc.", 76: "Tur
@mstaflex
mstaflex / mac_connected_ap.py
Created June 11, 2014 14:57
Monitor the connection state to an Access Point on a Mac OS computer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Tool to output the state of connection to an AP on a Mac OS computer.
Usage:
mac_connected_ap.py [options] [-q | -v] INTERFACE...
Arguments:
@mstaflex
mstaflex / dBm.py
Created March 10, 2014 11:30
Script to play around with efficient dBm calculations and correct logarithmic averages
from math import pow, log10
# ----------------------------------------------
rss = [rss for rss in range(-100, 21)]
rss_watt = [pow(10, s / 10.) for s in rss]
def get_rss_in_mwatt(rss_in_dbm):
assert 20 >= rss_in_dbm >= -100
return rss_watt[int(round(rss_in_dbm)) + 100]
@mstaflex
mstaflex / distribute_files.py
Last active August 29, 2015 13:57
This Python script monitors a given folder (recursive) for changes and synchronizes them with a remote station. Additionally to that it also (re-)starts a tmux session with the given main application script after a change.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A tool to distribute currently developed files to a remote station,
whenever they are changed.
Usage:
distribute_files.py PATH APP [options]
distribute_files.py -c CONFIG [options]
@mstaflex
mstaflex / rc.local
Last active August 29, 2015 13:56
Script that launches a complete twistbot tmux environment
# let us run the script on startup of the station
# this files lays under /etc/rc.local and is executed on boot of the system
su tbot -c 'source /home/tbot/.bashrc && /home/tbot/ros/twistbot-tmux-init.bash'