Skip to content

Instantly share code, notes, and snippets.


Matteo Cafasso noxdafox

View GitHub Profile
noxdafox /
Created Mar 18, 2020
AverageWebServices is so bad it requires you to attach EBS volumes to its crappy EC2 instances
# Attach AverageWebServices EBS volume to EC2 instance.
# Usage: <region> <instance-name> <device-name> <mount-point>
# Example: eu-west-1 my-ec2-instance /dev/xvdc /data
noxdafox /
Last active Oct 16, 2019
Collection of bash tricks
# Average file size in folder
# Credits:
ls -l | awk '{s+=$5} END {print "Average file size: " s/NR/1024 "k"}'
# Clear Docker related data
docker kill $(docker ps -q) # Kill running containers
docker rm $(docker ps -a -q) # Remove existing containers
docker rmi $(docker images -q) # Remove images
docker rmi $(docker images -q -f dangling=true) # Remove untagged images
noxdafox / conflict.clp
Last active Feb 28, 2019
This snippet shows the behaviour of a simple CLIPS rule set with different conflict resolution strategy.
View conflict.clp
(deftemplate complaint
(slot customer))
(deftemplate manager
(slot name)
; managers have a list of assigned customers
(multislot assigned-customers))
(deffunction respond-to-customer (?customer ?message)
(printout t "Dear " ?customer ", " crlf ?message crlf))
noxdafox /
Last active Jun 14, 2019
Usage example of RabbitMQ exchange deduplication plugin
import pika
from hashlib import md5
RABBITMQ_URL = 'amqp://guest:guest@localhost:5672/'
parameters = pika.URLParameters(RABBITMQ_URL)
connection = pika.BlockingConnection(parameters)
channel =
# Declare exchange, queue and bind them together
noxdafox /
Created Apr 15, 2018
This code snippet shows how to wrap a concurrent.futures.Executor class to provide a limited queue size.
from threading import BoundedSemaphore
from concurrent.futures import ProcessPoolExecutor
class MaxQueuePool:
"""This Class wraps a concurrent.futures.Executor
limiting the size of its task queue.
If `max_queue_size` tasks are submitted, the next call to submit will block
until a previously submitted one is completed.
You can’t perform that action at this time.