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 / 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

Numbers everyone should know

           0.5 ns - CPU L1 dCACHE reference
           1   ns - speed-of-light (a photon) travel a 1 ft (30.5cm) distance
           5   ns - CPU L1 iCACHE Branch mispredict
           7   ns - CPU L2  CACHE reference
          71   ns - CPU cross-QPI/NUMA best  case on XEON E5-46*
         100   ns - MUTEX lock/unlock
         100   ns - own DDR MEMORY reference
         135   ns - CPU cross-QPI/NUMA best  case on XEON E7-*
@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 / dict_is_not_a_mistery.md
Last active March 26, 2018 13:43
Dict is not a mystery