Skip to content

Instantly share code, notes, and snippets.

View maxfischer2781's full-sized avatar

Max Kühn maxfischer2781

  • Karlsruhe, Germany
View GitHub Profile
@maxfischer2781
maxfischer2781 / multiprocess_gc.py
Created November 27, 2018 15:53
Test for behaviour of GC in python multiprocessing using regular/shared objects
import multiprocessing
import time
import sys
process_identifier = 'main'
class Collectible:
def __init__(self, identifier):
self.identifier = identifier
@maxfischer2781
maxfischer2781 / switch.py
Created July 12, 2018 14:23
A class based implementation of a switch "statement" for Python
def switch(on):
def switch_decorator(cls):
for try_case in cls.__dict__.values():
try:
switch_case = try_case.__switch_case__
except AttributeError:
pass
else:
print(switch_case, '?')
if on == switch_case:
@maxfischer2781
maxfischer2781 / async_read.py
Last active April 7, 2025 02:10
example implementation for an async event loop
import time
import select
import socket
class AsyncSleep:
"""Event and action to sleep ``until`` a point in time"""
def __init__(self, until):
self.until = until
@maxfischer2781
maxfischer2781 / reify.py
Created June 16, 2018 19:02
relative map based on abstract operations
#!/usr/bin/python3
"""
Draft for a relative ``map`` based on abstract operations
.. function:: map(function, iterable, ...)
.. function:: reify(operation, iterable)
Apply the relative ``operation`` to every element of ``iterable``.
For example, ``reify(relative[0], [(1, 2, 3), range(5), "foobar"])`` returns ``[1, 0, 'f']``.
@maxfischer2781
maxfischer2781 / condor_usage.py
Last active July 4, 2018 08:26
extract user resource request data from condor_history
import os
import chainlet
import subprocess
import hashlib
import sys
import collections
from chainlet.protolink import iterlet
@maxfischer2781
maxfischer2781 / compare_whitelist.py
Created February 9, 2018 13:30
Compare an ALICE namespace to a catalogue whitelist
#!/usr/local/bin/python3
import os
import argparse
import pickle
import time
from typing import Set, Iterable
import chainlet
from chainlet.concurrency import threads
@maxfischer2781
maxfischer2781 / condor_anon_stat.py
Created December 15, 2017 14:41
Anonymization for job statistics from HTCondor
#!/usr/bin/python
import sys
import json
import random
import time
import argparse
import hashlib
def load_data(source):
@maxfischer2781
maxfischer2781 / compile_whitelist.py
Last active February 6, 2018 17:16
Transform an ALICE catalogue dump to a hierarchy of whitelists
#!/usr/local/bin/python3
import argparse
import chainlet
from chainlet.concurrency import threads
import pickle
import os
import time
import datetime
CLI = argparse.ArgumentParser("Transform an ALICE catalogue dump to a hierarchy of whitelists")
@maxfischer2781
maxfischer2781 / alice-migration.sh
Last active August 3, 2017 12:21
Script to launch a migration of an XROOTD namespace conforming to the ALICE VO conventions
NAMESPACE=${NAMESPACE:-"/export/xrootd/"}
RSYNC_ADDR=${RSYNC_ADDR:-"rsync://f01-120-179/alice-xrootd/"}
NS_START=${NS_START:-"00"}
NS_STOP=${NS_STOP:-"15"}
#!/bin/bash
if [[ "$*" =~ " -h" ]] || [[ "$*" =~ ^-h ]] || [[ "$*" =~ "--help" ]]
then
echo "usage:" >&2
echo " <script> [NAMESPACE [RSYNC_ADDR [NS_START NS_STOP]]]" >&2
echo "" >&2
@maxfischer2781
maxfischer2781 / xrd_crawl.py
Last active April 29, 2017 08:28
crawler for ALICE xrootd namespaces
from __future__ import print_function
import subprocess
import os
import argparse
import ast
import multiprocessing
import sys
import threading
import errno