Skip to content

Instantly share code, notes, and snippets.

View CorradoLanera's full-sized avatar
🏠
Working from home

Corrado Lanera CorradoLanera

🏠
Working from home
View GitHub Profile
@CorradoLanera
CorradoLanera / unique_chr-df.md
Last active December 6, 2017 00:39
[R] Provide Unique string among columns in a data frame
library(tidyverse)  # devtools::install_github('tidyverse/tidyverse')
#> -- Attaching packages -------------------------------------------------------------------------------- tidyverse 1.2.1 --
#> v ggplot2 2.2.1     v purrr   0.2.4
#> v tibble  1.3.4     v dplyr   0.7.4
#> v tidyr   0.7.2     v stringr 1.2.0
#> v readr   1.1.1     v forcats 0.2.0
#> -- Conflicts ----------------------------------------------------------------------------------- tidyverse_conflicts() --
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag()    masks stats::lag()
@CorradoLanera
CorradoLanera / 01-pkgsetup-renv.R
Last active July 10, 2022 18:32
Script to start the development of R projects/packages in a reproducible way
#' ---
#' title: "Setup (with `{renv}`)"
#' author: "Corrado Lanera"
#' date: "`r date()`"
#' output:
#' html_document:
#' toc: true
#' toc_float: true
#' keep_md: true
#' ---
@CorradoLanera
CorradoLanera / tf-example.py
Created July 8, 2019 23:06
Python TensorFlow working example on signals
# import os utilities
import os
import requests, zipfile, io
# import numpy
import numpy as np
# images
import skimage
from skimage import transform
@CorradoLanera
CorradoLanera / imported-modules.py
Created July 8, 2019 23:22
Print the modules currently imported in a python sesson
import types
def imports():
for name, val in globals().items():
if isinstance(val, types.ModuleType):
yield val.__name__
print(list(imports()))
@CorradoLanera
CorradoLanera / my-optimized-blas.md
Created July 9, 2019 20:35
My personal configuration for optimized BLAS LAPACK for R (debian 10)
sudo apt-get install libopenblas-base
sudo update-alternatives --config libblas.so.3-x86_64-linux-gnu # check openblas/libblas.so.3
sudo update-alternatives --config liblapack.so.3-x86_64-linux-gnu # select lapack/liblapack.so.3 
@CorradoLanera
CorradoLanera / optimized-tf-r-debian
Last active May 14, 2020 12:06
[summer 2019] My process to optimize tensorflow for R 3.6.1 on Debian 10, Dell-xps 13 9650
R package tensorflow use the conda envirnment "r-tensorflow". hence I have to install my compiled version of tf within that environment
1. update system and python
```
sudo apt-get update
sudo apt-get upgrade
```
2. install and update conda, and anaconda
```
# download tarbal from https://www.zotero.org/download/
# xvzf fro .bz, xvjf for .bz2
sudo tar xvjf Zotero-5.0.70_linux-x86_64.tar.bz2 -C /opt/
cd /opt/Zotero_linux-x86_64
sudo ./set_launcher_icon
# if not already present symlink to the menu
ln -s /opt/zotero/zotero.desktop ~/.local/share/applications/zotero.desktop
@CorradoLanera
CorradoLanera / install-R-source
Last active July 28, 2020 06:45
Basic step to install old versions of R for RStudio Server Pro
# examples for R-4.0.2
sudo wget https://cran.r-project.org/src/base/R-4/R-4.0.2.tar.gz
sudo tar -xvzf R-4.0.2.tar.gz
cd R-4.0.2
# install in /opt/R to make it automatically discovered by RSSP
sudo ./configure --prefix=/opt/R/$(cat VERSION) --enable-memory-profiling --enable-R-shlib --with-blas --with-lapack
sudo make
sudo make install
@CorradoLanera
CorradoLanera / .travis.yml
Last active February 9, 2020 15:35
R Travis-CI conf for rstan rstantools
# CL personal adjustment form https://discourse.mc-stan.org/t/rstan-rstantools-travis/6102
language: R
sudo: true
cache: packages
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
r_packages:
@CorradoLanera
CorradoLanera / R-benchmark-31.R
Last active May 14, 2020 11:56
[20200514] optimize blas lapack for R (4.0.0)
# R Benchmark 3.1 (05/2020) [Corrado Lanera]
# version 3.1 changed default random generator packages and functions
# given that the older ones are deprecated, R 4.0.0 @ Xeon 2.4GHz Ubuntu 10.04.4 LTS
# R Benchmark 2.5 (06/2008) [Simon Urbanek]
# version 2.5: scaled to get roughly 1s per test, R 2.7.0 @ 2.6GHz Mac Pro
# R Benchmark 2.4 (06/2008) [Simon Urbanek]
# version 2.4 adapted to more recent Matrix package
# R Benchmark 2.3 (21 April 2004)
# Warning: changes are not carefully checked yet!