Skip to content

Instantly share code, notes, and snippets.

@jrosell
jrosell / compute-risk-ratio-risk-difference.R
Last active September 26, 2025 07:36
Methods for computing Risk Ratio and Risk Difference.
stopifnot(requireNamespace("rlang"))
rlang::check_installed("pak")
pkgs <- rlang::chr(
"tidymodels",
"marginaleffects",
"parameters",
"modelbased",
"dplyr",
"stringr",
"tibble",
@dgkf
dgkf / cols.R
Last active September 12, 2025 18:26
dplyr at home
#' Column selector for `[` and `[[`
#'
#' @param ... Column names provided as `character` or `symbol` (could be
#' extended to allow other inputs!)
#' @return A `numeric` vector of column indices to select
#'
#' @examples
#' mtcars[cols(cyl, wt)] |> head()
#'
#' mtcars[cols(mpg:wt)] |> head()
@thyngster
thyngster / ga4CookieParser.js
Created April 12, 2025 06:01
GA4 COOKIES PARSER
/**
* Parses GA4 cookies using a measurement ID without polluting the global namespace
* @param {string} measurementId - GA4 measurement ID (e.g., 'G-XXXXXXXX')
* @returns {Object|null} Parsed GA4 cookie data or null if cookies not found
*/
function parseGA4Cookies(measurementId) {
function getCookieValue(name) {
const match = document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)');
return match ? match.pop() : null;
}
library(tidyverse)
library(gutenbergr)
constitution_raw <- gutenberg_download(5)
constitution <- constitution_raw |>
slice(36:546) |>
filter(text != "") |>
mutate(text_lc = str_to_lower(text)) |>
mutate(is_article = str_starts(text_lc, "article")) |>
@skkzsh
skkzsh / alert.org
Last active November 19, 2024 16:59
org-mode syntax

Note

Note

Tip

Tip

@dceddia
dceddia / bench.sh
Created November 15, 2024 18:30
Language benchmarks
#!/bin/bash
# Function to measure execution time
measure_time() {
start_time=$(date +%s.%N)
"$@"
end_time=$(date +%s.%N)
execution_time=$(echo "$end_time - $start_time" | bc)
echo "Execution time: $execution_time seconds"
}
library(magick)
library(lofifonts) # remotes::install_github('coolbutuseless/lofifonts')
library(purrr)
bitmap_text_coords("Hello", font = 'unifont') |>
head()
text <- glue::glue("It is a period of civil war.
Rebel spaceships, striking
from a hidden base, have won
@natzir
natzir / fuzzy-booster-by-natzir-mlforseo.ipynb
Created October 10, 2024 08:13
Fuzzy Booster by Natzir - MLforSEO
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#' @export
new_schedule_builder <- function() {
builder <- list(
sec = "0",
min = "0",
hour = "0",
dom = "*",
month = "*",
dow = "*",
year = "*"
``` r
A <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), nrow = 3, ncol = 4)
B <- matrix(c(13, 14, 15, 16, 17, 18, 19, 20), nrow = 4, ncol = 2)
dot_product <- function(x, y) {
mapply(\(x, y) sum(x * y), x, y)
}
rows_of <- function(m) purrr::array_tree(m, 1)
cols_of <- function(m) purrr::array_tree(m, 2)