Skip to content

Instantly share code, notes, and snippets.

View adamhsparks's full-sized avatar
🇦🇺

Adam H. Sparks adamhsparks

🇦🇺
View GitHub Profile
@adamhsparks
adamhsparks / reward_crash.txt
Created July 26, 2025 09:29
RKWard Crash Report macOS 15.5
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: rkward [45470]
Path: /Applications/rkward.app/Contents/MacOS/rkward
Identifier: org.kde.RKWard
Version: 0.8.1 (0.8.1)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
@adamhsparks
adamhsparks / nvim-r.txt
Created March 4, 2025 05:55 — forked from navicore/nvim-r.txt
R cheatsheet and nvim-r commands
Menu entry Default shortcut~
Start/Close
. Start R (default) \rf
. Start R (custom) \rc
--------------------------------------------------------
. Close R (no save) \rq
. Stop (interrupt) R :RStop
-----------------------------------------------------------
@adamhsparks
adamhsparks / openpgp.md
Created June 16, 2024 07:40
Keyoxide proof
@adamhsparks
adamhsparks / dpird_cvt_sf.R
Last active April 17, 2024 06:00
Get DPIRD CVT Zones as an {sf} Object in Your R Session
# get DPIRD CVT zones from the Public Services Slip WA as an {sf} object in R
# data are CC 4.0 and available from: <https://data.wa.gov.au/slip>
wfs_wa <-
"https://public-services.slip.wa.gov.au/public/services/SLIP_Public_Services/Boundaries_WFS/MapServer/WFSServer"
url <- httr2::url_parse(wfs_wa)
url$query <- list(service = "wfs",
#version = "2.0.0", # facultative
request = "GetCapabilities")
@adamhsparks
adamhsparks / historical_weather.py
Created March 27, 2024 06:47
Fetch historical weather data with Python using various packages
# Fetch historical weather data with Python using various packages
# use plotnine for graphing
from plotnine import *
import pandas as pd
import pathlib
# pynasapower
# Fetches NASA POWER data
@adamhsparks
adamhsparks / df_to_power.R
Last active March 14, 2024 06:01
Use a data frame of lonlat and date values to get data from POWER API using {nasapower}
library("nasapower")
library("purrr")
library("dplyr")
df <- data.frame(
stringsAsFactors = FALSE,
lon = c(151.81, 112.5, 115.5),
lat = c(-27.48, -55.5, -50.5),
date = c("3/3/2023", "5/12/2023", "1/3/2024")
)
@adamhsparks
adamhsparks / gist:5c82d48c31b5c22d0974fbeafb2f9ad1
Created February 19, 2024 06:42
Owner avatar OceanOmics-classifier-comparison trial run.R
- Project '~/tmp/OceanOmics-classifier-comparison' loaded. [renv 1.0.3]
> targets::tar_make()
> dispatched target all_results_files
o completed target all_results_files [0 seconds]
> dispatched branch all_results_ecfccd47
o completed branch all_results_ecfccd47 [0 seconds]
> dispatched branch all_results_eccc5a34
o completed branch all_results_eccc5a34 [0 seconds]
> dispatched branch all_results_05574669
o completed branch all_results_05574669 [0 seconds]
@adamhsparks
adamhsparks / wa_web_feature_services.R
Last active November 13, 2023 11:50
Use Western Australia's Web Feature Services in R
# Get all DPIRD boundary data sets available from the Public Services Slip WA and save data for use in an R package.
# HT to Thierry Onkelinx, Hans Van Calster, Floris Vanderhaeghe for their post,
# <https://inbo.github.io/tutorials/tutorials/spatial_wfs_services/>, but I
# modified this to work to save .Rds files for use in an R package, not just
# saving to disk and chose to use {httr2} in place of {httr}.
# NOTE: This URL is only for public boundaries,
<https://public-services.slip.wa.gov.au/public/services/SLIP_Public_Services/Boundaries_WFS/MapServer/WFSServer>,
there are others, see <https://catalogue.data.wa.gov.au/dataset> for other orgs and types of data
@adamhsparks
adamhsparks / quietly_wOz_stations.R
Last active October 17, 2023 02:46
Given a list of named places, get a list of weather stations in R from {weatherOz} or capture the message if no stations were found
# Find stations in both the DPIRD and SILO weather station networks given a
# vector of locations or capture messages when no stations are found
library("tidygeocoder")
library("data.table")
library("weatherOz")
library("purrr")
# Step 1: Create a vector of named locations to geocode
@adamhsparks
adamhsparks / StatQuantileBin.R
Created April 16, 2023 11:39 — forked from eliocamp/StatQuantileBin.R
Percentogram (histogram with bins of equal number of observations)
StatQuantileBin <- ggplot2::ggproto("StatQuantileBin", ggplot2::StatBin,
default_aes = ggplot2::aes(x = ggplot2::after_stat(density), y = ggplot2::after_stat(density), weight = 1),
compute_group = function(data, scales,
binwidth = NULL, bins = 30, breaks = NULL, trim = 0,
closed = c("right", "left"), pad = FALSE,
flipped_aes = FALSE,
# The following arguments are not used, but must
# be listed so parameters are computed correctly
origin = NULL, right = NULL, drop = NULL,