Skip to content

Instantly share code, notes, and snippets.

View program--'s full-sized avatar
🚀

Justin Singh-M. - NOAA program--

🚀
View GitHub Profile
@program--
program-- / Building-R-Statically.md
Last active January 31, 2024 05:19
Building R statically

Note

This is a work-in-progress.

This is an attempt at creating standalone R executables by embedding and evaluating R code through C via a static R build.

Currently, by using the below script, we receive libR.a and associated BLAS/LAPACK internal shared libraries. libR.A is ~6MiB, but is halved to ~3.3MiB when stripped. However, it's not completely static at this point, as some dependencies like PCRE are still dynamically linked (which, might be due to needing --enable-static=pcre or something?)

@program--
program-- / .clang-format
Last active August 20, 2023 00:47
Clang Format
---
Language: Cpp
BasedOnStyle: Mozilla
UseTab: Never
IndentWidth: 4
ColumnLimit: 80
DerivePointerAlignment: false
PointerAlignment: Left
AlignAfterOpenBracket: BlockIndent
AlignConsecutiveMacros: AcrossEmptyLines
@program--
program-- / install_spatial.md
Last active January 21, 2021 02:35
Bash script for installing GEOS, PROJ, and GDAL from source on Fedora

Description

This script installs GEOS, PROJ, and GDAL (with Python and NetCDF) from source on Fedora (Only tested with Fedora 33).

The user can specify versions and/or whether to install PROJ datum data with the flags below.

Partially credited to: https://gist.github.com/robinkraft/2a8ee4dd7e9ee9126030

It is generally recommended to install these libraries directly with yum/dnf.

This script should only be used if a specific version is needed.

@program--
program-- / download_hand_cfim.R
Created December 20, 2020 06:03
Download zipped HUC 6-digit HAND packages from CFIM Data Repository
#' Download from CFIM
#' Download zipped HUC 6-digit HAND packages from CFIM Data Repository - https://cfim.ornl.gov/data/
#' @param huc6_codes character vector of HUC 6-digit codes, or "all" to download all available HUC 6-digit zip files.
#' @param dir character of directory path.
#' @param overwrite Overwrite already downloaded zip files? Defaults to FALSE.
#' @return No explicit return. Unzipped HUC 6-digit HAND packages can be found in `dir`
#' importsFrom RCurl getURL
#' importsFrom stringr str_extract_all
#' importsFrom magrittr %>%
download_hand_cfim <- function(huc6_codes = "all", dir, overwrite = FALSE, ...) {
@program--
program-- / build_tree.R
Last active February 27, 2022 22:19
Convert gbm regression tree to data.tree
#' @title Build GBM Tree
#' @description Create a `data.tree` object from a GBM tree.
#' @param gbm_model Object of class `gbm`
#' @param i.tree Tree iteration to build from
#' @return A `data.tree` object from the `i.tree` tree of `gbm_model`.
build_tree <- function(gbm_model, i.tree = 1) {
gbm_tree <- gbm::pretty.gbm.tree(gbm_model, i.tree = i.tree)
pathString <- c("0" = "0")
for (node in seq(1, nrow(gbm_tree) - 1)) {
@program--
program-- / import_plan.R
Last active December 20, 2020 06:04
R function for getting an organized tibble from Microsoft Planner data (exported Excel spreadsheet).
#' Also see: https://github.com/program--/plannr
#' importsFrom readxl read_excel
#' importsFrom tibble as_tibble
import_plan <- function(xlsx) {
plan_data <- readxl::read_excel(xlsx)
plan_name <- colnames(plan_data[[2]][2])
plan_date <- plan_data[[2]][2]
filtered_data <- setNames(plan_data, plan_data[4, ])
filtered_data <- filtered_data[-c(1,2,3,4), ]