Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3f
import queue
import time
import serial
import serial.threaded
import traceback
from collections import namedtuple
from typing import Dict
# NOTE: setpoint may be None
@ulikoehler
ulikoehler / main.cpp
Created October 2, 2023 13:50
Motor pulse contorller
#include <Arduino.h>
constexpr int Pin_R_Enable = 14; // TODO
constexpr int Pin_L_Enable = 15; // TODO
constexpr int Pin_R_PWM = 16; // TODO
constexpr int Pin_L_PWM = 17; // TODO
constexpr int LEDC_CHANNEL_LEFT = LEDC_CHANNEL_0;
constexpr int LEDC_CHANNEL_RIGHT = LEDC_CHANNEL_1;
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
x = np.arange(0, 2*np.pi, 0.1)
y = np.sin(x)
fig = plt.gcf()
ax = plt.gca()
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
x = np.arange(0, 2*np.pi, 0.1)
y = np.sin(x)
fig = plt.gcf()
ax = plt.gca()
@ulikoehler
ulikoehler / HBridge.tex
Last active August 3, 2017 02:30
CircuiTikZ HBridge
% Simple CMOS (N-MOSFET & P-MOSFET) H bridge.
% Author: Uli Koehler (https://techoverflow.net)
% Based on http://texample.net/tikz/examples/power-electronics-converter-inverter/
% by Ali Mehrizi-Sani
%
% NOTE: Requires recent CircuiTikZ version in order to use [T]elmech and fetbodydiode!
% TeXLive 2015 is too old, please use at least TeXLive 2016!
\documentclass[tikz, border=1mm]{standalone}
\usepackage{siunitx}
@ulikoehler
ulikoehler / geneui.py
Created January 10, 2017 21:53
Generate a random 64-bit EUI for Python
#!/usr/bin/env python3
import random
print("bytes([{},{},{},{},{},{},{},{}])".format(
*[random.randint(0,255) for i in range(8)]))
using System;
namespace MathNet.Numerics
{
public struct Quaternion64 {
public double w, x, y, z;
public double NormSquared {
get {
return w * w + x * x + y * y + z * z;
# On public server:
socat -,raw,echo=0 tcp-listen:12345
# On private computer
socat tcp:localgrid.de:12345 'exec:"bash -i",pty,stderr,setsid,sigint,sane'
@ulikoehler
ulikoehler / po.patch
Created October 21, 2015 22:18
KA PO patch
diff --git a/poentry_linter.py b/poentry_linter.py
index e748d35..251555b 100644
--- a/poentry_linter.py
+++ b/poentry_linter.py
@@ -136,6 +136,9 @@ def _assert_same(po_entry, regexp, ka_locale, munge_fn=None):
for s in set(english_singular_counts.keys() +
english_plural_counts.keys() +
translated_counts.keys()):
+ # Hotfix for '"" occurs n times [...]' bug
+ if not s:
@ulikoehler
ulikoehler / Makefile
Last active August 29, 2015 14:27
LevelDB FUSE filesystem (pre-alpha)
all:
gcc -Wall levelfs.cpp `pkg-config fuse --cflags --libs` -o levelfs