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 / r67.R
Created September 7, 2024 16:24
Experimentation with R6 and S7 hybrid. Allows for the creation of mutable objects with type-safe properties as well as self-referential methods.
# What do i want from an object oriented R class system?
# opt-in public immutability - neither. Accomplished with private property with active binding in R6
# interior mutability - R6
# type safety - S7
# self-referential methods - R6
# private methods don't have any type safety they can be whatever you want.
# immutables can only be set at creation and class doesn't matter
# Each .public & .private element must be named
@JosiahParry
JosiahParry / gist:ad3d591738b3e284c590f8b35f10bd5a
Created September 7, 2024 14:08
spatial lag categorical development
# remotes::install_github("simonpcouch/forested")
library(dplyr)
library(sfdep)
library(spdep)
trees <- forested::forested |>
sf::st_as_sf(coords = c("lon", "lat"), crs = 4326)
k <- ceiling(nrow(trees)^(1/3))
@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 && \