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 / res.bad.txt
Last active September 13, 2018 16:28
5085 epoll_wait(4, [{EPOLLIN, {u32=2073779616, u64=94444109651360}}], 19, -1) = 1
5085 clock_gettime(CLOCK_REALTIME, {tv_sec=1536855916, tv_nsec=703944629}) = 0
5085 clock_gettime(CLOCK_MONOTONIC, {tv_sec=94121, tv_nsec=513469495}) = 0
5085 clock_gettime(CLOCK_BOOTTIME, {tv_sec=94121, tv_nsec=513573837}) = 0
5085 recvmsg(18, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\1\0\1(\0\0\0\2\0\0\0\271\0\0\0\1\1o\0\31\0\0\0", iov_len=24}], msg_iovlen=1, msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_CMSG_CLOEXEC) = 24
5085 recvmsg(18, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="/org/freedesktop/resolve1\0\0\0\0\0\0\0\3\1s\0\17\0\0\0ResolveHostname\0\2\1s\0 \0\0\0org.freedesktop.resolve1.Manager\0\0\0\0\0\0\0\0\6\1s\0\30\0\0\0org.freedesktop.resolve1\0\0\0\0\0\0\0\0\10\1g\0\4isit\0\0\0\0\0\0\0\7\1s\0\10\0\0\0:1.16495\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\0api.tumblr.com\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=224}], msg_iovlen=1, msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DO
@smurfix
smurfix / trio_graceful_shutdown.py
Last active July 31, 2018 18:35 — forked from sorcio/trio_graceful_shutdown.py
graceful service shutdown with Trio
from itertools import count
import signal
from async_generator import asynccontextmanager
import trio
async def monitor(self, task_status):
with trio.catch_signals({signal.SIGTERM}) as signal_aiter:
async with trio.open_nursery() as nursery:
task_status.started(nursery)
@smurfix
smurfix / compat.py
Last active July 27, 2018 01:12 — forked from vxgmichel/compat.py
Asyncio/Curio/Trio compatibility module
import asyncio
try:
import curio
except ImportError:
curio = None
try:
import trio
except ImportError:
@smurfix
smurfix / gist:65d7488aaab838f5b173af7cde7a3a9e
Created February 21, 2018 13:54
Single-step through trio without falling asleep
--- Lib/pdb.py 2018-02-15 14:49:47.668435454 +0100
+++ ../pdb.py 2018-02-21 14:48:21.039713323 +0100
@@ -246,6 +246,10 @@
that we ever need to stop in this function."""
if self._wait_for_mainpyfile:
return
+ if self.force_step(frame):
+ self.onecmd("step")
+ self.forget()
+ return
@smurfix
smurfix / README.md
Last active November 2, 2017 13:04 — forked from rduplain/README.md

This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object.

Running:

python manage.py runserver

gives "Hello, world!" on http://localhost:5000/, while running:

python manage.py -c development.cfg runserver

Keybase proof

I hereby claim:

  • I am smurfix on github.
  • I am matthiasu (https://keybase.io/matthiasu) on keybase.
  • I have a public key whose fingerprint is AFD7 9782 F3BA EC02 0B28 A19F 72CF 8E5E 25B4 C293

To claim this, I am signing this object:

#!/usr/bin/python
# Suppose you have, in InoReader, a folder "images" with a bunch of Tumblr streams.
# Suppose you want to skip everything in that stream *except* for large JPEGs which
# you have not seen before.
##
# InoReader doesn't have a feature for that.
# This is how to do it.
#
# This needs an enhanced librssreader, from github.com/smurfix/librssreader
import numpy
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import math
# Define test data.
points = numpy.float64([ 0., .17, .285, .365, .425, .47, .505, .532, .553, .571, .586 ])
xpos = numpy.float64(range(11))
# Define model function to be used to fit to the data above:
class BinData(ObjectRef):
"""
Stores (a reference to) one data file
This object implements a content-based file system: the hash of the
file contents is an index.
"""
storage_seq = Column(Integer, autoincrement=True, unique=True)
mime_id = Column(Integer, ForeignKey(MIMEtype.id), nullable=False, index=True)
mime = relationship(MIMEtype, primaryjoin=mime_id==MIMEtype.id)