Skip to content

Instantly share code, notes, and snippets.

@moritzmhmk
moritzmhmk / squircle.py
Created January 22, 2025 21:37
Python script to generate a "squircle" in svg format.
# Loosely based on the constants found by Liam Rosenfeld
# https://liamrosenfeld.com/posts/apple_icon_quest/
# Node coordinates
n1 = 0.63149379
n2 = 0.07491139
# Handle coordinates
h1 = 0.86840694
h2 = 0.37282383
h3 = 0.16905956
@moritzmhmk
moritzmhmk / lono-thermo-hygro-BLE.js
Created October 5, 2023 10:33
Read and parse data from the "Lono Thermo Hygro" sensor.
/**
* Copyright 2023 moritzmhmk.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the “Software”),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@moritzmhmk
moritzmhmk / switchbot-th-outdoor.js
Last active September 2, 2023 12:26
Read SwitchBot Indoor/Outdoor Thermo-Hygrometer
const noble = require('@abandonware/noble');
noble.on('stateChange', async (state) => {
if (state === 'poweredOn') {
await noble.startScanningAsync([], false);
}
});
noble.on('discover', async (peripheral) => {
if (peripheral.address !== "d5:c4:31:13:41:98") return
@moritzmhmk
moritzmhmk / utils.elm
Created November 10, 2021 17:18
Elm Utils
-- source: https://thoughtbot.com/blog/debugging-dom-event-handlers-in-elm
loggingDecoder : Decoder a -> Decoder a
loggingDecoder realDecoder =
Decode.value
|> Decode.andThen
(\event ->
case Decode.decodeValue realDecoder event of
Ok decoded ->
Decode.succeed decoded
$ raspivid -t 0 -w 1280 -h 720 -fps 25 --codec H264 --intra 75 --inline --flush -o - | ffmpeg -i pipe:0 -codec copy -f v4l2 /dev/video1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moritzmhmk
moritzmhmk / HifiBerryCaseCoverDigi.md
Last active October 30, 2020 13:54
HiFiBerry Case Cover for the HiFiBerry Digi+
@moritzmhmk
moritzmhmk / HLS.md
Last active April 23, 2020 08:19 — forked from mrbar42/README.md
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X)

running:

bash create-vod-hls.sh beach.mkv

will produce:

    beach/
      |- playlist.m3u8
 |- 360p.m3u8

run.sh

#!/bin/bash
xset s off &
xset -dpms &
xset s noblank &
unclutter &
chromium-browser\
 --window-position=0,0\
 --window-size=$(cat /sys/class/graphics/fb0/virtual_size)\
[Unit]
Description=Set up loopback cameras
[Service]
ExecStartPre=/sbin/modprobe v4l2loopback devices=3
ExecStart=/usr/bin/ffmpeg -f video4linux2 -input_format yuv420p -video_size 1280x720 -i /dev/video0 -codec copy -f v4l2 /dev/video1 -codec copy -f v4l2 /dev/video2 -codec copy -f v4l2 /dev/video3
Restart=always
RestartSec=2
[Install]