Skip to content

Instantly share code, notes, and snippets.

View marc-hanheide's full-sized avatar
💭
coding?

Marc Hanheide marc-hanheide

💭
coding?
View GitHub Profile
@marc-hanheide
marc-hanheide / vpn_ros_hostname
Last active August 29, 2015 14:02
to set the ROS_HOSTNAME from a ppp address in an /etc/hosts file
export ROS_HOSTNAME=`grep \`ifconfig | grep -A1 ppp | grep inet | cut -f2 -d:| cut -f1 -d" "\` /etc/hosts | tr -s " " | cut -f2 -d " "`
echo "ROS_HOSTNAME set to $ROS_HOSTNAME"
@marc-hanheide
marc-hanheide / ssh-tmux
Created October 6, 2014 16:00
automatically start tmux in interactive ssh sessions (to be used in .bashrc)
case $- in
*i*) # interactive shell
if [ -z "$TMUX" ]; then
if [ "$SSH_CLIENT" ]; then
TMUX_SESSION=`echo ${SSH_CLIENT} | cut -f1 -d" "`
echo "checking for tmux session with ID $TMUX_SESSION"
if tmux has-session -t "$TMUX_SESSION" > /dev/null; then
exec tmux at -t "$TMUX_SESSION"
else
@marc-hanheide
marc-hanheide / release.sh
Created October 22, 2014 15:47
Releasing packages to the official rosdistro
# if the rosdistro has been reconfigured to use another version,
# bloom needs to be told to use the official one with this env variable:
ROSDISTRO_INDEX_URL=https://raw.github.com/ros/rosdistro/master/index.yaml bloom-release -r indigo -t indigo mongodb_store
@marc-hanheide
marc-hanheide / gist:1e3ab2c1e0abbc0e7c1c
Created October 24, 2014 10:29
disable reverse-path filtering for all interfaces
sudo sysctl -a | grep \\.rp_filter | cut -f1 -d" " | xargs -i{} -- sudo sysctl -w {}=0
@marc-hanheide
marc-hanheide / install
Last active August 29, 2015 14:08
Build jekyll debian packages from ruby gem
# taken from https://github.com/jordansissel/fpm/wiki/ConvertingGems#convert-a-gem-and-all-of-its-dependencies
sudo apt-get install ruby1.9.3 rubygems
mkdir /tmp/gems
gem1.9.3 install --no-ri --no-rdoc --install-dir /tmp/gems jekyll
find /tmp/gems/cache -name '*.gem' | xargs -rn1 fpm -d ruby1.9.3 -d rubygems --gem-gem /usr/bin/gem1.9.3 -s gem -t deb
@marc-hanheide
marc-hanheide / autossh.sh
Last active August 29, 2015 14:10
autossh connection for ROS live streaming
# enable reverse port forwarding in firewall settings:
# 8181: mjpegserver
# 9090: rosws
# 22222: reverse ssh
AUTOSSH_POLL=5 AUTOSSH_FIRST_POLL=5 autossh -M 6000 harek -R8181:localhost:8181 -R9090:localhost:9090 -R22222:localhost:22
# put this in your `.ssh/config`
Host harek
TCPKeepAlive yes
ServerAliveInterval 20
@marc-hanheide
marc-hanheide / lines.m
Last active August 29, 2015 14:13
Lines intersections in 3D (MATLAB)
%%%%%%%%%
% Generate some test data, here 4 points p with directions d
% the position of the offset of the lines
p=[0 0; 1 0; 0 1; 1 1]';
% the direction for the individual lines, not sure if this is the format that is needed or if you have the rotation matrix.
% If the latter then simply multiply take the first row of the rotation matrix as d_i
d=[1 1; -1 1; 1 -1; -1 -1]';
@marc-hanheide
marc-hanheide / nm-reconnect.sh
Created February 25, 2015 09:15
reconnect NetworkManager to a specific network everytime it's lost
# every minute check if connection is still alive and try reconnecting if it's not
*/1 * * * * /usr/bin/nmcli c status id STRANDS-AAF > /dev/null || /usr/bin/nmcli c up id STRANDS-AAF
@marc-hanheide
marc-hanheide / check-disk.sh
Last active August 29, 2015 14:21
check disk and mail root if >80%
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom|none|udev' | awk '{ print $5 " " $1 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 80 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep%" root
fi