Skip to content

Instantly share code, notes, and snippets.

View zeehio's full-sized avatar

Sergio Oller zeehio

View GitHub Profile
@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:
@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 / gen-statistics.sh
Last active February 17, 2023 08:37
Generate HTML page with CPU, RAM, and disk usage information for several SSH servers.TODO: There are too many SSH connections per server. Fixing that would speed up a lot the HTML generation.
#!/bin/bash
# Shell script to get disk usage, cpu usage, RAM usage,system load,etc.
# from multiple Linux servers and output the information on a single
# server in html format. Read below for usage/installation info
# *--------------------------------------------------------------------*
# * ORIGINAL WORK BY:
# * dig_remote_linux_server_information.bash,v0.1
# * Last updated on 25-Jul-2005*
# * Copyright (c) 2005 nixCraft project *
# * Comment/bugs: http://cyberciti.biz/fb/ *
@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 / keybase.md
Created December 29, 2021 09:31
Keybase

Keybase proof

I hereby claim:

  • I am zeehio on github.
  • I am zeehio (https://keybase.io/zeehio) on keybase.
  • I have a public key whose fingerprint is 40B1 F8F3 B43C F786 4ED1 A0B6 20DA 0569 6BEB 2330

To claim this, I am signing this object:

import os
def _clamp(x, min, max):
if x < min:
return min
if x > max:
return max
return x
def _read_cpu_quota_limit_cgroup():
@zeehio
zeehio / test.Rmd
Last active July 17, 2020 16:23
Reproduce Rstudio diagnostics spurious warnings
---
title: "Untitled"
author: "test"
date: "17/7/2020"
output: html_document
---
```{r}
xy <- tibble::tibble(
y = c(1, 2, 3, 4, 5, 6),
@zeehio
zeehio / fix_espeak_mycroft.sh
Created April 13, 2018 07:30
How to make Spanish espeak say 'mycroft' properly
#!/bin/sh
# 1. Check that espeak fails to transcribe mycroft:
echo "How espeak transcribes 'hola mycroft':"
espeak -v spanish -x -q --pho "hola mycroft"
# 'ola mik**'Oft
echo "How espeak should transcribe 'hola mycroft':"
espeak -v spanish -x -q --pho "hola máicroft"
# 'ola m'aik**Oft
@zeehio
zeehio / extract_moodle_files.py
Created October 16, 2015 10:09
Copy files from moodle mbz into an ordered directory tree.
#!/usr/bin/env python3
"""
Moodle provides a backup system for courses offering an mbz file. This is a zip file with
all the resources and files included and the needed metadata about the files encoded in XML.
This script gets an unzipped mbz directory and copies all the files from the course into
a directory tree with the same layout than the original moodle course.
unzip my_moodle_backup.zip
extract_moodle_files.py --source my_moodle_backup_FILES --destination sorted_course