Skip to content

Instantly share code, notes, and snippets.

View zeehio's full-sized avatar

Sergio Oller zeehio

View GitHub Profile
@zeehio
zeehio / requests_truststore.py
Last active October 24, 2024 07:52
Use requests with truststore from a package
# Use requests with truststore from a package
#
# from requests_truststore import requests
# resp = requests.get("https://google.com")
from requests import Session
from requests.adapters import HTTPAdapter
import ssl
import truststore
@zeehio
zeehio / build-libxp6-guide.sh
Last active August 14, 2024 04:28
Build libxp6 on Ubuntu 24.04
#!/bin/bash
# WARNINGS:
# (1) Do not run this script with sudo permissions
# (2) Ideally, run this script line by line (the sed commands span multiple lines, please run all the sed commands at once)
# (3) You should change the NAME_EMAIL value accordingly.
# (4) The libxp6 package is old and unmaintained. It may have security issues.
# (5) The package build scripts are getting old and unmaintained as well. They are using more and more deprecated features.
# (6) Warning (5) means that for 26.04 this script may not work anymore without changes
# (7) I am not really interested in making the changes for 26.04.
@zeehio
zeehio / S3_double_dispatch.md
Created June 6, 2024 05:10
Example using double dispatch on S3.
doubledispatch <- function(x,y) {
  z <- list()
  z_classes <- expand.grid(
  cl_x=class(x),
  cl_y=class(y)
  )
  z_classes$cl_z <- paste0(
    z_classes$cl_x,
 "_",
@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 / 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 / 80-mount-usb-to-media-by-label.rules
Last active November 14, 2024 13:50 — 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 / 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),