Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xia-stan
xia-stan / README-python-service-on-systemd-activated-socket.md
Created January 29, 2021 13:47 — forked from drmalex07/README-python-service-on-systemd-activated-socket.md
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at /opt/foo/serve.py.

@xia-stan
xia-stan / README-setup-socket-activated-systemd-service.md
Created February 1, 2021 14:54 — forked from drmalex07/README-setup-socket-activated-systemd-service.md
An example inetd-like socket-activated service. #systemd #inetd #systemd.socket

README

This is an example of a socket-activated per-connection service (which is usually referred to as inetd-like service). A thorough explanation can be found at http://0pointer.de/blog/projects/inetd.html.

Define a socket unit

The key point here is to specify Accept=yes, which will make the socket accept connections (behaving like inetd) and pass only the resulting connection socket to the service handler.

@xia-stan
xia-stan / pixie16_list_mode_converter.py
Last active February 11, 2022 22:39
Converts Pixie-16 list-mode data files to a variety of other filetypes
""" SPDX-License-Identifier: Apache-2.0 """
import argparse
import json
from io import BytesIO
import logging
import os
import sys
from dolosse.hardware.xia.pixie16.list_mode_data_mask import ListModeDataMask
from dolosse.hardware.xia.pixie16.list_mode_data_decoder import decode_listmode_data
@xia-stan
xia-stan / support-90.py
Last active August 23, 2022 21:55
A script generated as part of SUPPORT-90 to convert list-mode data files to JSONL.
""" SPDX-License-Identifier: Apache-2.0 """
import argparse
import json
import logging
import os
import struct
import sys
import dolosse.constants.data as dcd
from dolosse.hardware.xia.pixie16.list_mode_data_mask import ListModeDataMask
@xia-stan
xia-stan / dirent.h
Created August 9, 2022 13:15 — forked from isakbosman/dirent.h
A Windows compatible dirent API (dirent.h)
/*
* dirent.h - dirent API for Microsoft Visual Studio
*
* Copyright (C) 2006-2012 Toni Ronkko
*
* 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
@xia-stan
xia-stan / hqsg-microdxp-8ff2aa54.c
Created February 23, 2024 14:49
Update to the hqsg-microdxp.c file from our internal repository.
/*
* This code accompanies the XIA Application Note
* "Handel Quick Start Guide: microDXP".
*
* Copyright (c) 2004-2015 XIA LLC
* All rights reserved
*/
#include <math.h>
#include <stdio.h>