Skip to content

Instantly share code, notes, and snippets.

@xia-stan
xia-stan / dirent.h
Created Aug 9, 2022 — forked from isakbosman/dirent.h
A Windows compatible dirent API (dirent.h)
View 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 / support-90.py
Created Feb 16, 2022
A script generated as part of SUPPORT-90 to convert list-mode data files to JSONL.
View support-90.py
""" 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 / pixie16_list_mode_converter.py
Last active Feb 11, 2022
Converts Pixie-16 list-mode data files to a variety of other filetypes
View pixie16_list_mode_converter.py
""" 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 / README-setup-socket-activated-systemd-service.md An example inetd-like socket-activated service. #systemd #inetd #systemd.socket
View README-setup-socket-activated-systemd-service.md

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 / README-python-service-on-systemd-activated-socket.md An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation
View README-python-service-on-systemd-activated-socket.md

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.