Skip to content

Instantly share code, notes, and snippets.

View onjin's full-sized avatar

Marek Wywiał onjin

View GitHub Profile
@onjin
onjin / feature-toggles-memo.md
Last active August 29, 2019 13:03
Categories of feature toggles

Feature toggles types

Short memo from:

Release Toggles

For not finished / not tested features

  • Configuration type: static - per environment, f.i. enabled only on test/stage
  • Lifetime: Short - until feature is finished / tested
@onjin
onjin / python_code_profiling.md
Last active March 6, 2019 13:19
python code profiling

requirements

Install https://github.com/jrfonseca/gprof2dot

Run profiler

$ python -m cProfile -o profiler.pstats ./some/python/code.py
$ gprof2dot -f pstats profiler.pstats | dot -Tpng -o profiler.png  # generate PNG calltree image
$ pyprof2calltree -i profiler.pstats -k # debug with kcachegrind
@onjin
onjin / modularity.md
Last active December 6, 2018 13:18
software modularity
@onjin
onjin / tests_responsibilities.md
Last active February 12, 2019 11:58
tests responsibilities
@onjin
onjin / nju-cli.py
Created November 21, 2018 21:48
example of writing cli program
#!/usr/bin/env python
import argparse
import getpass
import sys
from contextlib import contextmanager
from distutils.util import strtobool
def yes_or_no(question, default='no'):
"""Ask question and wait for yes/no answer.
# Rebind prefix key
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Pretty colors
# set -g status-bg blue
# set -g status-fg white
# Bindings
#!/bin/bash
xhost +
docker run \
--rm \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $(pwd)/:/data/ \
-ti eferro/freemind /freemind.sh $(id -u) $*
"""Start interactive console on SIGUSR1 signal.
run:
$ python ./sigusr1_debug.py
and in another window
$ ps aux|grep sigusr1_debug
$ kill -10 [process pid]
and in first window you get:
.
Signal received : entering python shell.
<?php
file_put_contents('latest.zip', fopen('https://wordpress.org/latest.zip', 'r'));
system('unzip ./latest.zip');
system('rm ./latest.zip');
system('mv wordpress/* .');
system('rmdir wordpress');