Skip to content

Instantly share code, notes, and snippets.

View shelonik's full-sized avatar

Shelonik Anton shelonik

View GitHub Profile
def f():
for cluster in range(10000):
expression = f'"cluster_id" = {cluster}'
layer = QgsProject.instance().mapLayersByName('turn_cluster_trajectories')[0]
layer.setSubsetString(expression)
if len(layer) == 0:
continue
layer = QgsProject.instance().mapLayersByName('normalized_trace_turns')[0]
layer.setSubsetString(expression)
qgis.utils.iface.zoomToActiveLayer()
from textwrap import wrap
import re
import itertools
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix
def plot_confusion_matrix(
@shelonik
shelonik / .tmux.conf
Created July 29, 2019 19:28
My tmux config
set -g mouse on
# Vim-like panel navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# remap prefix from 'C-b' to 'Alt-e'
unbind C-b
def set_random_seed(seed_value, use_cuda=True):
np.random.seed(seed_value) # cpu vars
torch.manual_seed(seed_value) # cpu vars
random.seed(seed_value) # Python
os.environ['PYTHONHASHSEED'] = str(seed_value) # Python hash buildin
if use_cuda:
torch.cuda.manual_seed(seed_value)
torch.cuda.manual_seed_all(seed_value) # gpu vars
torch.backends.cudnn.deterministic = True #needed
torch.backends.cudnn.benchmark = False
@shelonik
shelonik / Dockerfile
Created June 21, 2019 16:58
Dockerfile for research docker container build
# version 1.0
FROM ubuntu
RUN \
apt-get update && \
apt-get install -y \
vim \
git
RUN \
@shelonik
shelonik / ssh_server_up.sh
Last active June 21, 2019 16:51
After start of a container you should run `service ssh restart` to work. Password: docker
apt-get install -y openssh-server && \
sed -i "\$aPasswordAuthentication yes\nPermitRootLogin yes" /etc/ssh/sshd_config && \
echo 'root:docker' | chpasswd
set smarttab
set smartindent
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
@shelonik
shelonik / install_protoc3.sh
Last active May 25, 2019 15:13
The script will install the latest stable version of the protoc3 compiler in your system.
#! /bin/bash
TEMP_DIR=/tmp
VERSION=`curl --silent "https://api.github.com/repos/protocolbuffers/protobuf/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")'`
echo "Version $VERSION will be installed"
[[ -z VERSION ]] && echo "Could not get version from github"
@shelonik
shelonik / TF allow_growth
Created March 24, 2019 11:10
Toggle tensorflow to only allocate memory it needs instead of all
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
set_session(tf.Session(config=config))
@shelonik
shelonik / nbextensions_vim_install.sh
Last active March 22, 2019 09:37
Installing jupyter nbextensions to user, nbextensions server, vim-bindings and enable them
pip install jupyter_contrib_nbextensions
pip install jupyter_nbextensions_configurator
pip install yapf
jupyter contrib nbextension install --user
jupyter nbextensions_configurator enable --user
# Installation of vim_bindings
mkdir -p $(jupyter --data-dir)/nbextensions
# Now clone the repository
cd $(jupyter --data-dir)/nbextensions