Skip to content

Instantly share code, notes, and snippets.

# Python3
VENV_NAME=.venv
python3 -m venv $VENV_NAME --copies
. ${VENV_NAME}/bin/activate
python -m pip install --upgrade pip
# Python 2
#!/usr/bin/env bash
set -e
BLOGNAME=${1:-myblog}
echo "building $BLOGNAME"
mkdir $BLOGNAME
# bundle initialization and local configuration
@riccardo1980
riccardo1980 / GithubActionsPytestFlake8.md
Last active February 9, 2024 20:19
Basic GitHub Actions for linting/testing using flake8 and pytest

linting/testing base GitHub Action (flake8 & pytest)

You will find template of required files (requirements.txt, requirements-test.txt, project_package/base.py, tests/base_test.py, python-app.yml) at the end of this gist.

  1. Add base functionality and test files:
    • project_package/base.py
    • tests/base_test.py
  2. Add test requirements
    • requirements-test.txt
  3. Check whether your folders and files structure looks like:
# Following official howto at:
# https://kubernetes.io/docs/tasks/tools/install-minikube/
set -e
ret=$(sysctl -a | grep -E --color 'machdep.cpu.features' | sed -n 's/.*\(VMX\).*/\1/p')
if [[ $ret == 'VMX' ]]; then
echo 'VT-x feature is enabled'
else
echo 'VT-x feature is NOT enabled'
source /etc/vim/vimrc
set tabstop=4 " TAB width
set softtabstop=4 " TAB columns
set expandtab " Expand TABs to spaces
set shiftwidth=4 " Indentation width
" Remember last position
if has("autocmd")
@riccardo1980
riccardo1980 / pandas_utils.py
Created December 2, 2018 11:05
Split Pandas data frame by hash of observation features
import hashlib
import pandas as pd
def split_train_test_by_id(data, test_ratio=0.2, id_column=None, hash=hashlib.md5):
"""
Reproducible train test split: uses hash of string concatenation of observation
"""
def _test_set_check(identifier, test_ratio, hash):
return ord( hash(identifier).digest()[-1] ) < 256 * test_ratio