Skip to content

Instantly share code, notes, and snippets.

@eagafonov
eagafonov / readme.md
Last active March 14, 2018 20:44
Secure Docker cheatsheet

Run daemon with TLS enabled

/usr/bin/dockerd -H tcp://127.0.0.1:2736 \
    --tls --tlsverify  \
    --tlscacert /path/to/ca.pem \
    --tlscert /path/to/server.pem \
    --tlskey path/to/server_decrypted.key

Client settings

from functools import reduce, wraps
def dec1(func):
print("dec1: Decorating", func)
@wraps(func)
def wrapper(*args, **kwargs):
print("dec1: Calling {}(args={},kwargs={})".format(func.__name__, args, kwargs))
return func(*args, **kwargs)
@eagafonov
eagafonov / gitlab_registry_cleanup.md
Created December 5, 2017 14:06
How to cleanup Gitlab's Registry

Omnibus Gitlab

  1. Dry run
/opt/gitlab/embedded/bin/registry garbage-collect /var/opt/gitlab/registry/config.yml --dry-run
  1. Do clean up

/opt/gitlab/embedded/bin/registry garbage-collect /var/opt/gitlab/registry/config.yml

# Example with https://github.com/eagafonov/json_schema_helpers
import json_schema_helpers as jsh
heading_loc_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "heading_loc object",
"type": "object",
"additionalProperties": False, # properties must contains a complete list of supported languages
"properties": {
'''
Run as
> python3 gil_vs_threads.py 2> /dev/null
'''
import threading
import sys
the_value = 0
@eagafonov
eagafonov / public_ip.md
Created August 17, 2017 09:41
Get public IP address from Command LIne
@eagafonov
eagafonov / certbot.sh
Last active May 9, 2017 21:11
Shell-wrapper for docker-based certbot
#!/bin/sh
set -x
set -e
exec docker run --rm -ti \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /var/www/acme:/var/www/acme \
certbot/certbot $@
@eagafonov
eagafonov / gitlab_access.md
Last active March 15, 2017 11:52
GitLab access instructions (template)

How to get an access to you-gitlab-URL

There are just 3 simple steps to start pushing some stuff to gitlab using SSH

  1. Sign-up or request new account
  2. Generate SSH keys
  3. Upload SSH key to GitLab
  4. Update ~/.ssh/config for non-standart SSH port
@eagafonov
eagafonov / docker_cleanup.md
Last active February 28, 2020 00:44
Docker cleanup commands
  • Remove stoppped containers

    docker rm $(docker ps -a -q --filter status=exited)

  • Delete all 'untagged/dangling' () image

    docker rmi $(docker images -q -f dangling=true)

  • Remove ALL unused images > docker rmi $(docker images --format={{.Repository}}:{{.Tag}})

@eagafonov
eagafonov / add_floating_route.sh
Created March 14, 2016 12:33
[DigitalOcean] Simple script to route outgoing traffic through Floating IP
#!/bin/bash -x
set -e
# https://www.digitalocean.com/community/tutorials/how-to-use-floating-ips-on-digitalocean
DESTINATION_IP=$1
shift || (echo "E: Destination IP is not provided. Aborting"; exit 1)
ANCHOR_GW=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/gateway)