Skip to content

Instantly share code, notes, and snippets.

View trebidav's full-sized avatar

David Třebický trebidav

  • Prague
View GitHub Profile
### Keybase proof
I hereby claim:
* I am trebidav on github.
* I am davidtrebicky (https://keybase.io/davidtrebicky) on keybase.
* I have a public key ASCYBU0uIIM1cfJc2Ov8ReNkiCRkD1gvZXN2e0pUmD1xogo
To claim this, I am signing this object:
import json
import boto3
import urllib.request
import os
import ipaddress
import math
def lambda_handler(event, context):
IP_RANGES_URL = os.getenv('IP_RANGES_URL', "https://ip-ranges.amazonaws.com/ip-ranges.json")
SECURITY_GROUPS = os.getenv('SECURITY_GROUPS', [])
import json
import boto3
import urllib.request
import os
import ipaddress
import math
def split(arr, count):
return [arr[i::count] for i in range(count)]
@trebidav
trebidav / icinga2.conf
Created August 10, 2018 09:43 — forked from vachanda/icinga2.conf
Nginx config for icinga2 web interface.
server {
listen *:80;
server_name www.icinga2.com;
root /usr/share/icingaweb2/public; #Path of icinga2 web directory
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location = /favicon.ico {

Container in Python 3

PyCon CZ workshop on making a container using Python

Prerequisites

  • Python3

Instructions

from pyroute2 import IPDB, IPRoute
import os
def create_veth_path(fd):
ip = IPDB()
# create interface pair
ip.create(ifname='pycoz0', kind='veth', peer='pycoz1').commit()
ip.release()
setup_ip('pycoz0', '10.0.0.1/24')
import os
groups_types = {'cpu': '/sys/fs/cgroup/cpu/system.slice/',
'memory': '/sys/fs/cgroup/memory/system.slice/'}
def create_cgroups(name):
for group, path in groups_types.items():
if os.path.exists(path):
target = os.path.join(path, name)
@trebidav
trebidav / cont.py
Last active June 4, 2018 09:37 — forked from rwngwn/cont.py
#!/usr/bin/env python3
# goo.gl/bRsdYQ
import ctypes
import os
from multiprocessing import Process
CLONE_NEWUSER = 0x10000000
CLONE_NEWPID = 0x20000000
apiVersion: v1
kind: Namespace
metadata:
name: devel
apiVersion: v1
kind: ServiceAccount
metadata:
name: devel-admin
namespace: devel
http://www.linkedin.com/in/davidtrebicky
davidtrebicky@gmail.com
FIT CVUT
Linux
Automation
Ansible
Docker
Gitlab