Skip to content

Instantly share code, notes, and snippets.

View pgorczak's full-sized avatar

Philipp Gorczak pgorczak

  • German Maritime Search and Rescue Service
  • Dortmund, Germany
View GitHub Profile
@pgorczak
pgorczak / ros-mdns
Created June 26, 2018 11:27
A tiny helper for setting up environment variables
# Put this file somewhere on your path
# run `source ros-mdns {master-hostname}`
export ROS_MASTER_URI=http://$1.local:11311
export ROS_HOSTNAME=$(hostname).local
@pgorczak
pgorczak / plot_traffic.py
Created April 12, 2018 15:02
Example for plotting packets/second with scapy and matplotlib
#! /usr/bin/env python
import threading
from scapy.all import *
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.style
from matplotlib import animation
import numpy as np
@pgorczak
pgorczak / README.md
Last active March 29, 2018 09:10
Simplest half-duplex serial over Pycom LoRa

Dead simple serial-over-LoRa pipe using Pycom modules.

Note that this example is only half-duplex. You will need to implement some kind of flow control / media access control to be able to use it like a full duplex pipe.

@pgorczak
pgorczak / mininet_mptcp_example.py
Created March 14, 2018 11:13
Bare bones example for multipath TCP with mininet
import subprocess
from time import sleep
from mininet.net import Mininet
from mininet.node import Host, Switch
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.log import setLogLevel
from mininet.topo import Topo
@pgorczak
pgorczak / lte-transport-block-size.md
Last active August 2, 2019 17:45
LTE transport block size table in convenient json (Table 7.1.7.2.1-1 from 3GPP TS 36.213)

LTE transport block size

This is the lookup table linking the transport block size index (determined by modulation and coding scheme) and the number of resource blocks to an LTE transport block size. It's taken from 3GPP [TS 36.213][36.213] (Table 7.1.7.2.1-1) at version 15.0.0. Multiply a TBS by 1000 to get the max throughput in bps.

Heatmap of block sizes

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y gnuradio-dev \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y git cmake \
&& git clone git://github.com/BastilleResearch/gr-lora.git \
&& cd gr-lora \
&& mkdir build \
&& cd build \
@pgorczak
pgorczak / nginx.conf
Last active January 25, 2017 17:48
Demo: serving static content with nginx + mDNS
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
@pgorczak
pgorczak / activate.sh
Created December 8, 2016 20:22
Place this next to your linaro toolchain to cross compile for ARM
ROOT=$(realpath $(dirname $0))
LINARO=$ROOT/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf
# Use the toolchain
export BIN_PREFIX=$LINARO/bin/arm-linux-gnueabihf-
export CC=${BIN_PREFIX}gcc
export CXX=${BIN_PREFIX}g++
# Compile like $CXX hello_world.cpp -o hello
x, y, z, _, _, _ = kin.transform_to_pose(self.robot.transform)
# Check translation distance
# Ensure numeric stability of angle calculation
r_2 = np.linalg.norm((x, y, z))
if r_2 < 1e-5:
return
# Aim at tip frame with givens rotations
# First about z (yaw, azimuth) - eliminate y
r_1 = np.hypot(x, y)
c_1 = x/r_1
@pgorczak
pgorczak / connection.h
Last active June 8, 2016 19:39
Text based socket connection, using a UNIX socket in C++. Looks up hostname and port, checks if it can connect, sets timeouts. Corner cases of data spanning across socket reads should be covered.
#ifndef CONNECTION_H
#define CONNECTION_H
#include <netdb.h>
#include <stdexcept>
#include <string>
#include <sstream>
#include <sys/socket.h>
#include <deque>