This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| LOG_FILE="/Users/username/output.log" | |
| NOTIFIED_FILE="/Users/username/notified.txt" | |
| EMAIL="[email protected]" | |
| # Read the contents of the notified file, if it exists | |
| notified=$(cat "$NOTIFIED_FILE" 2>/dev/null) | |
| # If the notified file doesn't exist, assume no previous notification |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rextendr) | |
| rust_function(" | |
| fn rowmin(m: RMatrix::<i32>) -> Vec<i32> { | |
| // convert to an ndarray | |
| let matrix = <ArrayView2<i32>>::from_robj(&m).unwrap(); | |
| // store results | |
| let mut min_values = Vec::with_capacity(matrix.len()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Modify a vector in the workspace; x is a user-accessible symbol | |
| x <- 42 | |
| .Internal(inspect(x)) | |
| # @5631a3a19e20 14 REALSXP g0c1 [REF(5)] (len=1, tl=0) 42 | |
| x[1] <- 43 # modification causes a copy (address changes) | |
| .Internal(inspect(x)) | |
| # @5631a36c1cb8 14 REALSXP g0c1 [REF(4)] (len=1, tl=0) 43 | |
| ## Modify a vector inside a function; user cannot access y | |
| f <- function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Change (findFewestCoins) where | |
| import Data.List (find) | |
| import Data.List (minimumBy) | |
| import Data.Function (on) | |
| import Debug.Trace | |
| smallestLengthList :: [[Integer]] -> [Integer] | |
| smallestLengthList = minimumBy (compare `on` length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(shiny) | |
| ui <- fluidPage( | |
| titlePanel("Expand/Collapse DataTable"), | |
| mainPanel( | |
| fluidRow( | |
| column(6, DT::dataTableOutput("tbl")), | |
| column(6, DT::dataTableOutput("tbl2")) | |
| ) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dbg <- function(x) { | |
| ex <- rlang::f_text(rlang::enquos(x)[[1]]) | |
| ret <- rlang::eval_bare(x) | |
| message(glue::glue("DEBUG: {ex} = {ret}")) | |
| ret | |
| } | |
| a <- 1 | |
| b <- 3 | |
| x <- dbg(a + b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://notstatschat.rbind.io/2022/11/03/improving-a-graph/ | |
| d <- read.table( | |
| "https://gist.githubusercontent.com/tslumley/9ac8df14309ecc5936183de84b57c987/raw/9ebf665b2ff9a93c1dbc73caf5ff346909899827/busdata.txt", | |
| header = TRUE | |
| ) | |
| d$date <- as.Date(paste(2022, d$mo, d$d, sep = "-")) | |
| d$weekend <- with(d, weekdays(d$date) %in% c("Saturday", "Sunday")) | |
| d$workday <- with(d, !(weekdays(date) %in% c("Saturday", "Sunday"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| splt <- function(s) { | |
| x <- strsplit(s, "-") | |
| s[order(sapply(x, `[[`, 1), as.integer(sapply(x, `[[`, 2)))] | |
| } | |
| splt_radix <- function(s) { | |
| x <- strsplit(s, "-") | |
| s[order(sapply(x, `[[`, 1), as.integer(sapply(x, `[[`, 2)), method = "radix")] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Goal: reproduce e.g. https://www.reddit.com/r/oddlysatisfying/comments/uc054a/lissajous_polygons | |
| using Plots | |
| import GeometryBasics: Point | |
| ## https://jcarroll.xyz/2022/04/07/interpolation-animation-in.html | |
| interpolate(a, b) = t -> ((1.0 - t) * a + t * b) | |
| ## define the vertices of an N-gon |