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 / loadOrInstall.R
Created September 13, 2017 10:36
Install a R package if not already installed, then load it
loadOrInstall <- function(pkgname, CRANmirror.index=1) {
chooseCRANmirror(ind=CRANmirror.index)
if (! pkgname %in% installed.packages()[,1]) {
write("installing", stderr())
install.packages(pkgname, dep=T)
} else { write("already installed", stderr()) }
library(pkgname, character.only = TRUE)
write("loaded",stderr())
}

Keybase proof

I hereby claim:

  • I am keuv-grvl on github.
  • I am keuvgrvl (https://keybase.io/keuvgrvl) on keybase.
  • I have a public key whose fingerprint is 0D53 14FA F5B7 F41B 057D 9E19 FF46 2EC3 CA1D 38EE

To claim this, I am signing this object:

@keuv-grvl
keuv-grvl / mga-wrapper.py
Last active June 14, 2018 15:45
MetaGeneAnnotator wrapper. Display a progress bar while executing MGA.
#!/usr/bin/env python3
# MetaGeneAnnotator: http://metagene.nig.ac.jp/
import argparse
import sys
_VERSION = "0.3"
@keuv-grvl
keuv-grvl / vm.win7word
Created August 17, 2018 00:12
Run a Virtualbox VM in background and safely save its state if SIGINT is sent
#!/usr/bin/env bash
# trap signals
trap vmsavestate INT
function vmsavestate() {
cleaner=$(head -c $(( $(tput cols) - 1 )) < /dev/zero | tr '\0' ' ')
echo -en "\r${cleaner}\rSaving state of 'win7word' "
vboxmanage controlvm win7word savestate
}
@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,
@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 / 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 / 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 / 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
[user]
name = Keuv Grvl
email = k***@***m
[core]
quotepath = false
editor = vim
pager = less -F -x2
[init]
defaultBranch = main
[push]