Skip to content

Instantly share code, notes, and snippets.

View JosiahParry's full-sized avatar
💻
on the 'puter

Josiah Parry JosiahParry

💻
on the 'puter
View GitHub Profile
@JosiahParry
JosiahParry / Cargo.toml
Created September 6, 2024 20:08
testthat-cli R
[package]
name = "testthat-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
argh = "0.1.12"
#' @export
new_schedule_builder <- function() {
builder <- list(
sec = "0",
min = "0",
hour = "0",
dom = "*",
month = "*",
dow = "*",
year = "*"
@JosiahParry
JosiahParry / harris-trump-polls-538.R
Created July 24, 2024 21:08
A short script to read in all 2024 polling data from 534 and make a quick visualization.
library(dplyr)
library(tidyr)
library(ggplot2)
url <- "https://projects.fivethirtyeight.com/polls/president-general/2024/national/polls.json"
# read in the raw json path
polls_raw <- RcppSimdJson::fload(url)
# filter to the IDs that contain Harris
@JosiahParry
JosiahParry / attachments.md
Created July 3, 2024 18:28
working with attachments in arcgislayers
# install the development version
# install.packages("pak")
# pak::pak("r-arcgis/arcgislayers")
library(pillar)

# for authorizing to your portal
library(arcgisutils)
#> 
#> Attaching package: 'arcgisutils'
@JosiahParry
JosiahParry / keybindings.json
Last active August 17, 2024 00:46
Positron Keybindings
// Place your key bindings in this file to override the defaults
[
{
"key": "shift+cmd+b",
"command": "workbench.action.tasks.runTask",
"args": "Build R package",
"when": "isRPackage"
},
{
"key": "shift+cmd+enter",
@JosiahParry
JosiahParry / shrink.R
Created May 9, 2024 15:17
Draft of a script that removes all sorts of stuff from vendored rust crates to reduce size
#!/usr/bin/env Rscript
# we need to vendor the dependencies and then store the checksum
rextendr::vendor_pkgs()
# make the checksum
# writeLines(
# tools::md5sum("src/rust/vendor.tar.xz"),
# "./tools/vendor.md5"
# )
@JosiahParry
JosiahParry / Cargo.toml
Created April 28, 2024 18:47
Parse JSON files using only Rust.
[package]
name = "json-parser"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.199", features = ["derive"] }
serde_json = "1.0.116"
@JosiahParry
JosiahParry / Dockerfile
Last active April 19, 2024 14:55
fast UUID replacement
FROM python:3.9-bookworm
ENV R_VERSION=4.3.3
# Install from Posit binaries
# https://docs.posit.co/resources/install-r/#verify-r-installation
RUN apt-get update && \
apt-get install -y gdebi-core curl && \
curl -O https://cdn.rstudio.com/r/debian-12/pkgs/r-${R_VERSION}_1_amd64.deb && \
gdebi -n r-${R_VERSION}_1_amd64.deb && \
@JosiahParry
JosiahParry / single-page-pkg-doc.R
Created April 14, 2024 16:13
Create a single page function reference using base R and quarto.
# Current limitation is that the images that are used are relative to the
# package lib.loc / help so what might be idea lis to extract the image
# and base64 encode them using {b64}
pkg_to_quarto_doc <- function(pkg, out_path = paste0(pkg, ".qmd"), ...) {
tmp <- tempfile()
base_doc <- tools::pkg2HTML(pkg, out = tmp, ...)
# read in html
og <- rvest::read_html(tmp)
@JosiahParry
JosiahParry / lib.rs
Created April 5, 2024 15:03
1brc using DataFusion and extendr for R API
[package]
name = 'tst2'
publish = false
version = '0.1.0'
edition = '2021'
[lib]
crate-type = [ 'staticlib' ]
name = 'tst2'