Skip to content

Instantly share code, notes, and snippets.

View dmitryhd's full-sized avatar

Dmitry Khodakov dmitryhd

View GitHub Profile
@dmitryhd
dmitryhd / vegeta_load_test.md
Last active November 9, 2018 08:31
Vegeta POST JSON load test

To load test simple POST json

setup

brew update && brew install vegeta

Run

@dmitryhd
dmitryhd / line_profiler.py
Last active October 29, 2018 14:44
python line profiler
from line_profiler import LineProfiler
def profile_function(func, *args, **kwargs):
'''
Usage:
def long_function(x, y)
return x + y
z = profile_function(long_function, x=1, y=2)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
os.environ['MKL_DYNAMIC'] = '0'
os.environ['OPENBLAS_NUM_THREADS'] = '1'
os.environ['OMP_NUM_THREADS'] = '1'
import numpy
import ctypes
# linux only
mkl_rt = ctypes.CDLL('libmkl_rt.so')
mkl_get_max_threads = mkl_rt.mkl_get_max_threads
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmitryhd
dmitryhd / slackbot.py
Last active November 7, 2019 20:11
slackbot.py
__all__ = [
'SlackBot',
'RecBot',
]
import os
import time
import re
import subprocess
from functools import wraps
import matplotlib.pyplot as plt
import matplotlib
import seaborn as sns
%matplotlib inline
plt.rcParams["figure.figsize"] = (12., 7.)
%config InlineBackend.figure_format = 'retina'
sns.set_style('dark')
matplotlib.rc('font', family='Arial') # in case of missing cyrillic fonts
import warnings; warnings.filterwarnings("ignore") # font warning
@dmitryhd
dmitryhd / adv_logging.py
Last active July 22, 2017 12:24
Advanced logging
class WorkerLogger(logging.Logger):
# noinspection PyMethodOverriding
def _log(self, level, msg, args, exc_info=None, extra=None):
if extra is None:
extra = {'worker': 'noworker'}
super()._log(level, msg, args, exc_info, extra)
def configure_all_loggers():
logging.setLoggerClass(WorkerLogger)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.