This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Attach AverageWebServices EBS volume to EC2 instance. | |
# | |
# Usage: attach_ebs_volume.sh <region> <instance-name> <device-name> <mount-point> | |
# Example: attach_ebs_volume.sh eu-west-1 my-ec2-instance /dev/xvdc /data | |
# | |
aws_region=$1 | |
instance_name=$2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Average file size in folder | |
# Credits: http://www.bradlanders.com/2011/04/27/bash-one-liner-average-file-size-in-current-directory/ | |
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 | |
## one-liner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pika | |
from hashlib import md5 | |
RABBITMQ_URL = 'amqp://guest:guest@localhost:5672/' | |
parameters = pika.URLParameters(RABBITMQ_URL) | |
connection = pika.BlockingConnection(parameters) | |
channel = connection.channel() | |
# Declare exchange, queue and bind them together |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |