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 / windows_update.R
Last active August 27, 2022 02:32
I have finally found the Windows progress bar hidden algorithm!!
update_windows <- function() {
pb <- progress::progress_bar$new(
total = 100,
format = "(:spin) :what [:bar] :perc",
clear = FALSE,
width = 80
)
i <- 1
@CorradoLanera
CorradoLanera / tidy_redcap.R
Last active March 11, 2022 01:37
A prototype of function for make a redcap downloaded db more "uniforme" and usable for data analyses
# functions -------------------------------------------------------
separated_event_fup <- function(db) {
db |>
dplyr::mutate(
fup_id = .data[["ev_id"]] |>
stringr::str_extract("(?<=fup_)\\d") |>
as.integer(),
ev_id = .data[["ev_id"]] |>
stringr::str_extract("(?<=ev_)\\d") |>
as.integer()
@CorradoLanera
CorradoLanera / .Renviron
Last active July 15, 2021 08:16
My personalized R configuration files
_R_CHECK_LENGTH_1_CONDITION_ = TRUE
_R_CHECK_LENGTH_1_LOGIC2_ = TRUE
@CorradoLanera
CorradoLanera / app-future-into-api.R
Last active October 12, 2022 14:31
Shiny + future + plumber
#
# This is a Shiny web application. You can run the application by
# clicking the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
@CorradoLanera
CorradoLanera / logid.cfg
Last active November 23, 2021 23:39
my configuration file for logid driver (logitech on linux)
devices: (
{
name: "Wireless Mouse MX Master";
smartshift:
{
on: true;
threshold: 20;
};
hiresscroll:
{
@CorradoLanera
CorradoLanera / all_installed_by.R
Created November 17, 2020 10:50
Information of all packages possibly installed when `install.packages()` a package
'All installed by.
USAGE:
all_installed_by.R [-d] [-s] [-f=<FILE>] <PKG>...
all_installed_by.R [-d] [-s] [-f=<FILE>] -i
all_installed_by.R [-d] [-s] [-f=<FILE>] -c
all_installed_by.R (-h | --help)
OPTIONS:
-h --help Show this screen.
@CorradoLanera
CorradoLanera / get_domain.R
Last active July 9, 2020 18:09
Small vectorized function to extract domains in base R
#' Get domain
#'
#' @param url (chr) url from which extract the domain
#' @param include_suffix (lgl, default TRUE) would you like to get the
#' suffix too (dot included)?
#'
#' @seealso https://stackoverflow.com/questions/19020749/function-to-extract-domain-name-from-url-in-r
#' @export
#' @examples
#' get_domain("www.example.com")
@CorradoLanera
CorradoLanera / Htypes.R
Last active June 5, 2020 11:25
What Harrell's {Hmisc} thinks about "types". AKA: how to know (in advance) what will be `plot()`ted from an `Hmisc::describe()` object?
## You should have {Hmisc} to check what it produce :-)
requireNamespace("Hmisc", quietly = TRUE)
## If you would run the tests (you do not have to), you need {testthat}.
## TL;DR: passing tests won't produce any output!
can_test <- requireNamespace("testthat", quietly = TRUE)
## Note: for easy of notation I will call an object of class "describe"
## in the Harrell's world as "Hdesc" object (w/ capital H, in his
## honour).
@CorradoLanera
CorradoLanera / optimized-tf-r-ubuntu
Created May 14, 2020 19:26
[summer 2020] Optimized TF 2.2 r-tensorflow R4.0.0 Ubuntu 18.04
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
```
@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!