Skip to content

Instantly share code, notes, and snippets.

View smurfix's full-sized avatar
💭
Trio+Asterisk-ARI

Matthias Urlichs smurfix

💭
Trio+Asterisk-ARI
View GitHub Profile
@smurfix
smurfix / ring.py
Created December 17, 2022 22:54
Borromean Ring
"""
The purpose of this script is to mash three elongated toruses, linked as
Borromean Rings, into a single circular torus.
https://en.wikipedia.org/wiki/Borromean_ringshttps://en.wikipedia.org/wiki/Borromean_rings
The script starts in a state where the linked rings do not touch.
Then it reduces both elogation and angles in small steps, removing the
overlap and smoothing the resulting mesh every time, until the link
lies flat and is no longer stretched.
@smurfix
smurfix / wrap.py
Last active February 14, 2024 18:15
Trio: results-gathering nursery wrapper
#!/usr/bin/python3
import trio
import outcome
from contextlib import asynccontextmanager
class StreamResultsNursery:
def __init__(self, max_buffer_size=1):
self.nursery = trio.open_nursery()
self.max_buffer_size = max_buffer_size
@smurfix
smurfix / scaler.py
Last active December 10, 2021 11:57
Kicad scale footprint
#!/usr/bin/python3
from sexpdata import dump,load,Symbol, dumps as ds
import click
import sys
skip = set(("rotate",))
scaled = set(("xy","xyz","at","size","start","end"))
scaled_width = set(("thickness","width"))
[0:motion] [NTC] [ALL] [Dec 06 12:18:56] motion_startup: Motion 4.4.0 Started
[0:motion] [NTC] [ALL] [Dec 06 12:18:56] motion_startup: Using log type (ALL) log level (ALL)
[0:motion] [INF] [ALL] [Dec 06 12:18:56] conf_output_parms: Writing configuration parameters from all files (1):
[0:motion] [INF] [ALL] [Dec 06 12:18:56] Thread 0 - Config file: /etc/motion/motion.conf
[0:motion] [INF] [ALL] [Dec 06 12:18:56] daemon off
[0:motion] [INF] [ALL] [Dec 06 12:18:56] setup_mode off
[0:motion] [INF] [ALL] [Dec 06 12:18:56] pid_file
[0:motion] [INF] [ALL] [Dec 06 12:18:56] log_file /dev/stderr
[0:motion] [INF] [ALL] [Dec 06 12:18:56] log_level 9
[0:motion] [INF] [ALL] [Dec 06 12:18:56] log_type all
@smurfix
smurfix / motion.conf
Created December 6, 2021 09:54
motion JPEG bug
daemon off
setup_mode off
log_level 7
log_type all
input -1
rotate 0
width 1280
height 1024
framerate 5
minimum_frame_time 0
@smurfix
smurfix / gist:663b1004721d86aaf676bbe4c71ee303
Last active October 6, 2020 15:46
Sketch: console lookup
diff --git a/src/Host.cpp b/src/Host.cpp
index 73df2d40..10103f95 100644
--- a/src/Host.cpp
+++ b/src/Host.cpp
@@ -2598,3 +2598,13 @@ void Host::setCompactInputLine(const bool state)
}
}
}
+
+QPointer<TConsole> Host::findConsole(QString name)
@smurfix
smurfix / result_taskgroup.py
Last active January 9, 2024 09:31
anyio ResultGatheringTaskgroup
import anyio
from contextlib import asynccontextmanager
class NotYet(RuntimeError):
pass
class ResultGatheringTaskgroup:
def __init__(self):
self.result = []
@smurfix
smurfix / crash.logcat
Last active February 4, 2020 19:42
Fairphone 3. Reproducible by opening Settings and starting any app, basically. "Files" will do it.
02-04 18:45:04.978 21417 23932 E ChromeSync: [Sync,SyncAdapter] Failed to sync.
02-04 18:45:04.978 21417 23932 E ChromeSync: rfa: Error when calling the server (message: deadline exceeded after 9.997384271s. [buffered_nanos=9999504632, waiting_for_connection]).
02-04 18:45:04.978 21417 23932 E ChromeSync: at rjq.b(:com.google.android.gms@20104037@20.1.04 (120400-288960190):93)
02-04 18:45:04.978 21417 23932 E ChromeSync: at rjk.a(:com.google.android.gms@20104037@20.1.04 (120400-288960190):25)
02-04 18:45:04.978 21417 23932 E ChromeSync: at tcl.onPerformSync(:com.google.android.gms@20104037@20.1.04 (120400-288960190):9)
02-04 18:45:04.978 21417 23932 E ChromeSync: at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:334)
02-04 18:45:04.978 21417 23932 E ChromeSync: Caused by: ciwd: DEADLINE_EXCEEDED: deadline exceeded after 9.997384271s. [buffered_nanos=9999504632, waiting_for_connection]
02-04 18:45:04.978 21417 23932 E ChromeSync: at ciwc.c(:com.google.android.g
@smurfix
smurfix / mux.py
Last active September 7, 2021 08:33
example code for a multiplexing client/server protocol
#!/usr/bin/python3
"""
This is example code for a multiplexing client/server protocol.
Missing:
* server capacity management
* actual testcases for error propagation and cancellation
* handle badly-formatted messages without crashing the server
* sending more than one request or reply per interaction
import trio
import random
from collections import deque
WORKER_COUNT = 10
tasks = range(103)
class WorkQueue:
def __init__(self, workers):