Skip to content

Instantly share code, notes, and snippets.

View keuv-grvl's full-sized avatar

Keuv Grvl keuv-grvl

  • Bordeaux, France
View GitHub Profile
@keuv-grvl
keuv-grvl / wrap_tfop.py
Created October 20, 2021 08:09
Wrap TF op in Keras layer with lambda and closure
import tensorflow as tf
ReduceMean = lambda axis=1: tf.keras.layers.Lambda(lambda x: tf.reduce_mean(x, axis=axis))
i = tf.keras.layers.Input(shape=(5,15)) # shape: [BATCHSIZE, 5, 15]
m = ReduceMean(i) # shape: [BATCHSIZE, 15]
# TODO would be nice to have a wrapping function for any TF op with arbitrary
@keuv-grvl
keuv-grvl / .autoenv.sh
Created February 18, 2021 14:56
Autoactivate Conda env when entering a directory (using dir name or provided name).
# ln -s /path/to/this/.autoenv.sh /path/to/workdir/
if test -f .autoenv_conda_env_name ; then
TARGET_CONDA_ENV="$(cat .autoenv_conda_env_name)"
if [[ $TARGET_CONDA_ENV != $CONDA_DEFAULT_ENV ]]; then
conda activate "$TARGET_CONDA_ENV" 2&>1 2> /dev/null
fi
else
CUR_DIR=$(basename $(pwd))
conda activate "$CUR_DIR-dev" 2> /dev/null \
def perfboxplot(
setup,
kernels,
labels,
n=3,
xlabel="Performances",
equality_check=None,
save_path=None,
log_scale=True,
):
import numpy as np
import pandas as pd
import seaborn as sbn
from matplotlib import pyplot as plt
from scipy.stats import anderson
from sklearn import datasets
from sklearn.cluster import MiniBatchKMeans
from sklearn.preprocessing import scale, LabelEncoder
# TODO doc, memoization
[user]
name = Keuv Grvl
email = k***@***m
[core]
quotepath = false
editor = vim
pager = less -F -x2
[init]
defaultBranch = main
[push]
@keuv-grvl
keuv-grvl / fitsne_wrapper.py
Created March 8, 2019 16:55
FItSNE wrapper
class FItSNE_wrapper:
"""
Wrapper class for FItSNE `fast_tsne.fast_tsne` v1.1.0.
It is currently designed to work in a Conda environment with Python 3.7 and FFTW 3.
Install and compile as follow:
$ conda create -n YOUR-ENV python=3.7 fftw=3
$ source activate YOUR-ENV
@keuv-grvl
keuv-grvl / Makefile
Created February 19, 2019 14:42
Simple Makefile for LaTeX project
.PHONY: pdf display clean nuke
PDFREADER :=evince
OUTPUT :=document.pdf
BUILD :=build
SRC :=$(shell find src -name '*.tex' -o -name '*.png')
LMKFLAGS = -pdf -outdir=$(BUILD)
pdf: $(OUTPUT)
@keuv-grvl
keuv-grvl / unirefxml2fasta.py
Last active October 26, 2021 03:01
Convert UniRef XML to fasta. Mostly to rebuild previous UniRef databases
#!/usr/bin/env python3
import argparse
import gzip
import logging
import sys
from time import time
from lxml import etree
@keuv-grvl
keuv-grvl / toggle-vpn.sh
Last active August 21, 2018 00:31
Toggle a given VPN, eventually ask for password
#!/usr/bin/env bash
# usage: toggle-vpn.sh vpn-name
set -e # this script exits on error
set -o pipefail # a pipeline returns error code if any command fails
set -u # unset variables as an error, and immediately exit
command -v nmcli > /dev/null # ensure nmcli is installed
@keuv-grvl
keuv-grvl / properly.run.docker
Last active August 18, 2018 23:11
Properly run a Docker container which create files
#!/usr/bin/env bash
docker run \
--volume $(pwd):/data \
--user $(id -u $USER):$(id -g $USER) \
--entrypoint /path/to/your_program \
CONTAINER_NAME \
--input /data/inputfile --output /data/outputfile
# Will run '/path/to/your_program --input /data/inputfile --output /data/output' inside the container,