Skip to content

Instantly share code, notes, and snippets.

View tapionx's full-sized avatar

Riccardo Serafini tapionx

View GitHub Profile
@tapionx
tapionx / gist:0e28444c46193d0348597e05cd5dd515
Created February 29, 2024 10:11
Valid test UK phone number
+44 20 7123 4567
@tapionx
tapionx / monitor_docker_ram_usage.py
Created September 28, 2021 09:40
get maximum docker containers memory usage
import subprocess
from decimal import Decimal
class DockerStatsParser():
def __init__(self):
self.max_memory = 0
@tapionx
tapionx / network_bitrate.py
Created March 29, 2020 13:42
linux total network troughtput from all interfaces
import os
import time
def get_total_bytes(interfaces):
rx_bytes = 0
tx_bytes = 0
for interface in interfaces:
with open('/sys/class/net/{}/statistics/rx_bytes'.format(interface)) as f:
rx_bytes += int(f.read())
import os
import time
def get_total_bytes(interfaces):
rx_bytes = 0
tx_bytes = 0
for interface in interfaces:
with open('/sys/class/net/{}/statistics/rx_bytes'.format(interface)) as f:
rx_bytes += int(f.read())
version: "3.3"
services:
mm:
image: misi/mm:v3.2
working_dir: /opt/multiparty-meeting/server
entrypoint: ./mm_entrypoint.sh
restart: unless-stopped
image: misi/mm:latest
environment:
@tapionx
tapionx / advent_of_code_4.py
Created December 2, 2019 14:19
Advent of Code 2019 #4
for noun in range(99):
for verb in range(99):
with open('2_input.txt', 'r') as f:
input_program = [int(x) for x in f.read().strip().split(',')]
input_program[1] = noun
input_program[2] = verb
def execute_intcode(input_program):
program_counter = 0
while program_counter < len(input_program) and input_program[program_counter] != 99:
#print(program_counter, input_program[program_counter])
@tapionx
tapionx / advent_of_code_3.py
Created December 2, 2019 10:51
Advent of Code 2019 #3
with open('2_input.txt', 'r') as f:
input_program = [int(x) for x in f.read().strip().split(',')]
input_program[1] = 12
input_program[2] = 2
def execute_intcode(input_program):
program_counter = 0
while program_counter < len(input_program) and input_program[program_counter] != 99:
#print(program_counter, input_program[program_counter])
opcode = input_program[program_counter]
input1_address = input_program[program_counter + 1]
@tapionx
tapionx / 2.py
Created December 1, 2019 16:09
Advent of Code 2019 #2 solution
with open('1_input.txt', 'r') as f:
input_data = f.readlines()
def fuel_requirement(mass):
fuel_needed = (mass / 3) - 2
if fuel_needed > 0:
return fuel_needed + fuel_requirement(fuel_needed)
else:
return 0
print(fuel_requirement(14))
print(fuel_requirement(1969))
@tapionx
tapionx / 1.py
Created December 1, 2019 16:08
Advent of Code 2019 #1 solution
with open('1_input.txt', 'r') as f:
input_data = f.readlines()
def fuel_requirement(mass):
fuel_needed = (mass / 3) - 2
while fuel_needed > 0:
fuel_needed += (fuel_needed / 3) - 2
print(fuel_requirement(14))
print(fuel_requirement(1969))
print(fuel_requirement(100756))
fuel_sum = 0
@tapionx
tapionx / vpn.conf
Last active October 8, 2019 07:16
wireguard server ansible playbook (debian 10)
[Interface]
Address = 10.8.0.1/24
PrivateKey = XXXXXXXXXX
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = 51821
[Peer]
PublicKey = XXXXXXXXXX
AllowedIPs = 10.8.0.2/24