Skip to content

Instantly share code, notes, and snippets.

@mstaflex
mstaflex / vector_util.py
Last active December 27, 2015 19:29
Vektor operations (basic) in python - always need it - always reprogram it - until now ;)
import math
from math import sin, cos, pi
from numpy import dot, matrix, array
from numpy.linalg import norm
#import numpy as np
# author Jasper Buesch
def rotate_vector(angle=0, vector=(0,0)):
rot_mat = matrix( ((cos(angle),-sin(angle)), (sin(angle), cos(angle))) )
@mstaflex
mstaflex / ros.bash
Created February 10, 2014 13:55 — forked from mchwalisz/ros.bash
#!/bin/bash
RP_BASEDIR=~/Code/ros
export TURTLEBOT_BASE=kobuki
export TURTLEBOT_STACKS=hexagons
export TURTLEBOT_3D_SENSOR=kinect
# source /opt/ros/groovy/setup.bash
source /home/opt/ros-hydro-ws/install_isolated/setup.bash
@mstaflex
mstaflex / distribute.sh
Created February 25, 2014 14:22
Script that distributes all the ROS files from the central control station to the TWISTbots
#!/bin/bash
stations="tbot_unit01 tbot_unit02 tbot_unit03 tbot_unit04 tbot_unit05"
excluds="distribute build msg_gen srv_gen log packs"
# Author Jasper Buesch
####################################################################################
############# DO NOT CHANGE BELOW THIS #############################################
@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'
@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 / 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 / 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 / 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
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 / 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