Skip to content

Instantly share code, notes, and snippets.

@eagafonov
eagafonov / make-a-bug.sh
Last active March 27, 2024 20:29
GNU Make's bug (exec a directory)
#!/bin/sh
set -x
# Create a folder named 'docker'. The folder would have 'executible' flag set
mkdir -p `pwd`/scripts/docker
# Add the script to the path BEFORE the rest
export PATH=`pwd`/scripts:$PATH
@eagafonov
eagafonov / Makefile
Created January 15, 2022 00:41 — forked from jeffsp/Makefile
Easy way to embed help in a GNU make Makefile
.PHONY: target1 # Target 1 help text
target1: target2 target3
@echo "Target 1"
.PHONY: target2 # Target 2 help text
target2:
@echo "Target 2"
.PHONY: target3
@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)
@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 / effective-gitlab.md
Last active January 22, 2020 21:17
Effective GitLab

How to use GitLab and keep calm

Personal (and borrowd) best practices how to use GitLab Web-UI with high efficency. The author uses GitLab Community Edition

Long story short

  • issue boards
  • CI Linter
  • bookmarks to most-user projects and stuff
@eagafonov
eagafonov / py27_bound_unbound_method.txt
Created April 10, 2019 12:33
Check for bound/unbound class method (python2.7)
# class for autopsy
In [1]: class A:
...: def foo():
...: pass
# initial investigations
In [16]: str(A.foo)
@eagafonov
eagafonov / recovery_git_stash.md
Last active March 20, 2019 14:11
How to recover deleted stashes

How to recover deleted stash commits

TL;DR

git fsck --unreachable | grep commit | cut -d" " -f3 | xargs git log --merges --no-walk --grep=WIP

Original SO post.

import logging
# default config
logging.basicConfig()
# LogMessage attributes for FORMAT
# https://docs.python.org/3.5/library/logging.html#logrecord-attributes
FORMAT = '%(asctime)-15s %(message)s'
logging.basicConfig(format=FORMAT)
class GetAttrNotImplementedMixin:
methods_to_be_implemented = {'foo', 'bar'} # add more method names
def __getattr__(self, name):
def _method_not_implemented(*args, **kwargs):
raise NotImplementedError("Method %s is not implemented in class %s" % (name, self.__class__.__name__))
if name in self.methods_to_be_implemented:
return _method_not_implemented