Skip to content

Instantly share code, notes, and snippets.

View zeehio's full-sized avatar

Sergio Oller zeehio

View GitHub Profile
@zeehio
zeehio / ref-transp.md
Created February 17, 2022 10:41
Referencial transparency in R

Referencial transparency is a property of most programming languages, where the name of the variables does not affect the outcome.

Let's start with a simple example:

add1 <- function(variable) {
  return(variable + 1)
}

add1(1)
@zeehio
zeehio / 80-mount-usb-to-media-by-label.rules
Last active March 7, 2023 07:42 — forked from eklex/80-mount-usb-to-media-by-label.rules
udev rule for Home Assistant OS (hassio) to mount USB drives into the Supervisor Media directory
#
# udev rule
# Mount USB drive to the media directory using the partition name as mount point
#
# Description:
# Created for Home Assistant OS, this rule mounts any USB drives
# into the Hassio media directory (/mnt/data/supervisor/media).
# When a USB drive is connected to the board, the rule creates one directory
# per partition under the media directory. The newly created partition is named
# as the partition name. If the partition does not have a name, then the following
@zeehio
zeehio / numbering-chunks.Rmd
Created February 23, 2023 19:47
Inconsistency in chunk numbering
---
title: "Demo inconsistency"
author: ""
date: ""
output: html_document
---
```{r Chunk1}
Sys.sleep(5)
```
@zeehio
zeehio / delayed-array-bug.R
Created September 19, 2023 10:05
DelayedArray issue to be tested on main
reprex::reprex({
library(DelayedArray)
x <- DelayedArray(matrix(1L, nrow = 2, ncol = 1))
colnames(x) <- "potato"
# wrong:
df <- as.data.frame(x, drop = TRUE)
colnames(df)
# workaround: