Skip to content

Instantly share code, notes, and snippets.

View Hermann-SW's full-sized avatar

Hermann Stamm-Wilbrandt Hermann-SW

View GitHub Profile
@Hermann-SW
Hermann-SW / Germany.html
Created June 18, 2015 02:23
Google geochart sample at provinces resolution (Germany)
<!--
Google geochart of Germany at provinces resolution
https://stamm-wilbrandt.de/en/github/Germany.html
https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
@Hermann-SW
Hermann-SW / 120fps.2.html
Last active March 20, 2023 23:35
HTML5 120fps video player with single frame back+forward (Chrome/Firefox/Opera)
<!DOCTYPE html>
<!--
Based on this posting:
http://stackoverflow.com/questions/20336955/how-to-step-one-frame-forward-and-one-frame-backward-in-video-playback/20339938#20339938
v0.1: initial
v0.2: highlight key commands as buttons, fps snap-in time
v0.3: key commands -> button commands
v0.4: allow for "http[s]://....?t=7.07", pause video on fwd/bck/"|<"
-->
@Hermann-SW
Hermann-SW / gist:5b487ece9d62cf669caf
Created November 1, 2015 23:15
Measuring >40k interrupts per second by DS3231 32K and 8kHz enabled SQW lines on pins 2+3 of Arduino
// needed for RTC.set(_, _), see bottom as well
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
// from http://www.pjrc.com/teensy/td_libs_DS1307RTC.html
long lcnt=0;
void fcnt(void) { ++lcnt; }
@Hermann-SW
Hermann-SW / hextoppm.c
Created November 3, 2015 10:20
Convert Arduino ILI9341_due library "tft.screenshotToConsole()" Serial console output to .ppm picture file
/*
hex2ppm.c -- this is a hack.
(Arduino ILI9341_due library ILIScreenshotViewer is Windows only)
Just copy the hex line from Serial console to eg. "scr.hex" file.
Then "hex2ppm src.hex > src.ppm" (followed by ppmtojpeg if needed).
Sample "tft.screenshotToConsole();" output in serial console window:
==== PIXEL DATA START ====
0000000002 ... 1D4D0D4013F000015B8
@Hermann-SW
Hermann-SW / collatz_async.py
Created November 20, 2018 23:00
65 concurrent uasyncio worker threads on 28KB free RAM ESP-01s module MicroPython
import uasyncio as asyncio
N = 65
loop = asyncio.get_event_loop(runq_len = N+1)
def collatz(x):
yield x
while x!=1:
x = 3*x+1 if x%2==1 else x//2
yield x
@Hermann-SW
Hermann-SW / mp.js
Last active November 30, 2018 08:21
Node.js script allowing for remote MicroPython command execution
#!/usr/bin/env node
[scpt,pwd,host] = process.argv.slice(1);
cmd = process.argv.slice(4).join(" ");
out = 0;
last = "";
if (process.argv.length < 5) {
console.log((require("path")).basename(scpt) + " pwd host cmd [...]");
process.exit(1);
@Hermann-SW
Hermann-SW / local2gw
Created August 10, 2019 21:05
Reroute traffic for eg. eth0 IP address so that traffic goes through gateway instead of localhost (based on https://unix.stackexchange.com/a/128428 with one correction, one additon, and automatic determination of ip and gw; start eg. with "sudo ./local2gw eth0")
#!/bin/bash
if=$1
gw=`ip route show | grep "^default" | grep $if | cut -f3 -d\ `
vip=`ip route show table local | grep ^local | grep $if | cut -f2 -d\ `
# from https://unix.stackexchange.com/a/128428
ip route add local $vip dev lo table 10 proto kernel scope host
ip rule add to $vip lookup 10 prio 1
#
@Hermann-SW
Hermann-SW / stepperPTcamera.scad
Last active December 10, 2019 08:55
stepper Pan Tilt camera system: superglue connection of two 28BYJ-48 stepper motors
// stepper Pan Tilt camera system: superglue connection of two 28BYJ-48 stepper motors
//
// based on https://www.thingiverse.com/thing:204734 by RGriffoGoes
// https://forum.arduino.cc/index.php?topic=647703.0
//
module StepMotor28BYJ()
{
difference(){
union(){
color("gray") cylinder(h = 19, r = 14, center = true, $fn = 32);
# Live camera preview on main DPI display as well as HDMI0 monitor.
#
# Works only after running "rpi-update" until this commit will be available:
#
# https://github.com/raspberrypi/userland/commit/2549c149d8aa7f18ff201a1c0429cb26f9e2535a
#
# Values are Dispmanx display enums, therefore predominantly
# 0 = DSI/DPI LCD
# 2 = HDMI0
# 3 = SDTV
#!/bin/bash
fb="fb0"
vir_siz="/sys/class/graphics/$fb/virtual_size"
size=`stty size < /dev/tty`
echo -ne "\033[6n" < /dev/tty
read -s -d\[ garbage < /dev/tty
read -s -d R pos < /dev/tty