This file contains 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
ts=0.07;ps=0.02;A=B=0; | |
while(1){ j=i=0;z=rep(0,1760); | |
b=rep(' ',1760); while(j < 6.28){ | |
j=j+ts;i=0;while(i<6.28){i=i+ps;c= | |
sin(i);l=cos(i); d=cos(j);f=sin(j); | |
e=sin(A);g=cos(A );h=d+2;D=1/(c*h*e+ | |
f*g+5);m=cos(B) ;n=sin(B);t=c*h*g- | |
f*e;x=as.integer (40+30*D*(l*h*m-t*n)); | |
y=as.integer(12+ 15*D*(l*h*n+t*m)); | |
o=as.integer(x+( 80*y));N=as.integer( |
This file contains 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
enum <- function(...) { | |
vals <- if (is.null(...names())) { | |
setNames(seq_len(...length()), c(...)) | |
} else { | |
c(...) | |
} | |
out <- new.env(parent = emptyenv()) | |
list2env(as.list(vals), out) | |
lapply(names(vals), lockBinding, out) | |
lockEnvironment(out) |
This file contains 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
## Medical Term Fuzzy Grouping | |
## J. Carroll 2024 | |
## | |
## Uses the {zoomerjoin} package: https://github.com/beniaminogreen/zoomerjoin | |
## read in a set of medical terms, lowercased | |
terms <- tolower(readLines("https://raw.githubusercontent.com/socd06/medical-nlp/master/data/vocab.txt")) | |
## example data with typos and inserted words | |
gi <- c("gastrointestinal disorders", "gastrointestinal tract disorders", "gastreinstestinal disorder") |
This file contains 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="username@example.com" | |
# 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 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 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 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 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 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) |
NewerOlder