Skip to content

Instantly share code, notes, and snippets.

# A simple echo server, + instrumentation to detect event loop starvation
import time
from curio import run, tcp_server
from curio.socket import IPPROTO_TCP, TCP_NODELAY
last_addr = None
last_switch_loops = 0
last_switch_time = None
@njsmith
njsmith / aggressive-echo-client.py
Created November 13, 2016 07:47
fairness problems with the eager read/write optimization
import curio
received = 0
async def send(sock):
while True:
await sock.sendall(b"x" * 100000)
async def recv(sock):
global received
# Very simple netcat-like program
# 1) Accepts a connection on localhost:PORT1 (source)
# 2) Makes a connection to HOST:PORT2 (dest)
# 3) Forwards data from source to dest and vice-versa
# 4) Exits when done.
import sys
import curio
import curio.socket as csocket
@njsmith
njsmith / c99ish.c
Last active November 8, 2025 14:25
/* Silly little test file for some popular C99 features:
* - C++-style comments
* - variadic macros
* - 'static inline'
* - within-block variable declarations
* - designated initializers
* - stdint.h
* - stdbool.h
*
* Copyright (C) 2016 Nathaniel Smith <njs@pobox.com>
SELECT
COUNT(*) AS downloads,
REGEXP_EXTRACT(details.python, r'([0-9]+\.[0-9]+)') AS py_major_minor
FROM
TABLE_DATE_RANGE([the-psf:pypi.downloads], TIMESTAMP("20160601"), CURRENT_TIMESTAMP())
WHERE
file.project = 'scikit-image'
GROUP BY
py_major_minor
ORDER BY

tl;dr

I want to have a directory layout like:

  openssl/path/openssl.dylib
  client/path/client.bundle

where client.dylib is linked to openssl.dylib, and, crucially, I don't know the relative location of openssl.dylib and client.bundle until runtime -- openssl/path and client/path will both vary independently on different users' machines.

Then I want my process to do something like:

{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"package": {
"type": "object",
"additionalProperties": false,

Comparison of configuration file languages

We need to PEPify a static format for writing down bootstrap information in Python source trees. The initial target is a list of PEP 508 package requirement strings. It's possible that in the future we might want to add more features like a build system backend specification (as in PEPs 516, 517), or an extension namespace feature to allow third-party developer tools (flit, pytest, coverage, flake8, etc.) to consolidate their configuration in this file in a systematic

diff -ur glibc-2.20/ChangeLog glibc-linaro-2.20-2014.11/ChangeLog
--- glibc-2.20/ChangeLog 2014-09-07 01:09:09.000000000 -0700
+++ glibc-linaro-2.20-2014.11/ChangeLog 2014-10-22 08:03:50.000000000 -0700
@@ -1,3 +1,56 @@
+2014-10-08 Roland McGrath <roland@hack.frob.com>
+
+ [BZ #17460]
+ * nscd/nscd.c (more_help): Rewrite list of tables collection
+ using xstrdup and asprintf.
+
@njsmith
njsmith / gg
Created February 10, 2016 23:57
#!/bin/sh
exec git grep "$@"