Skip to content

Instantly share code, notes, and snippets.

View ar-puuk's full-sized avatar
💭
💩🚗

Pukar Bhandari ar-puuk

💭
💩🚗
View GitHub Profile
# DuckDB Vector Tiles with mapgl Example
# This script demonstrates how to serve vector tiles from DuckDB using ST_AsMVT()
# and display them in a mapgl map using httpuv
library(mapgl)
library(duckdb) # Requires the latest DuckDB version (>= 1.4.0)
library(httpuv)
library(sf)
library(duckspatial)
library(tigris)
## function to split "label: text" into data.frame(label = text)
v1 <- function(x) {  
  x <- gsub(": ", ":", x)  ## first clear that whitespace
  dd <- read.delim(text = x, sep = ":", header = FALSE); 
  setNames(data.frame(dd[[2]]), dd[[1]][1])
}

library(sf)
sf::sf_use_s2(FALSE)
@brancengregory
brancengregory / chrome_history.R
Created November 11, 2024 22:33
Chrome History in R with DuckDB
library(duckdb)
library(duckplyr)
library(dplyr)
chrome_history_path <- "./chrome_history.sqlite"
# Copy the db to the local directory because Chrome puts a lock on it
file.copy(
"~/.config/google-chrome/Default/History", # Adjust based on OS
chrome_history_path,
#' Aggregate sf objects
#'
#' Geometries and attributes are aggregated.
#'
#' @param x sf object
#' @param by name of the variable of grouping elements
#' @param var name(s) of the variable(s) to aggregate
#' @param fun function(s) to compute the summary statistics
#'
#' @return An sf object is returned
@ThioJoe
ThioJoe / Get_All_Shell_Folder_Shortcuts.ps1
Last active April 12, 2025 09:48
Fetches all shell folders from Windows Registry and creates a shortcut to each, while attempting to determine the proper name and icon. Also outputs CSV file with results.
# NOTE - THIS SCRIPT IS NOW OBSOLETE - SEE MY OTHER REPO FOR A MUCH MORE COMPREHENSIVE TOOL: https://github.com/ThioJoe/Windows-Super-God-Mode
# Get All Shell Folder Shortcuts Script (Updated 8/10/2024)
# Original source: https://gist.github.com/ThioJoe/16eac0ea7d586c4edba41b454b58b225
# This PowerShell script is designed to find and create shortcuts for all special shell folders in Windows.
# These folders can be identified through their unique Class Identifiers (CLSIDs) or by their names.
# The script also generates CSV files listing these folders and associated tasks/links.
# How to Use:
# 1. Open PowerShell and navigate to the path containing this script using the 'cd' command.
@kadyb
kadyb / zipped_shapefile.R
Last active May 16, 2025 01:54
Directly load and save zipped shapefiles in {sf}
library("sf")
file = system.file("shape/nc.shp", package = "sf")
shp = read_sf(file)
## write zipped shapefile
write_sf(shp, "myshapefile.shp.zip", driver = "ESRI Shapefile")
## read zipped shapefile
read_sf("myshapefile.shp.zip")
@nlxdodge
nlxdodge / windows_install.bat
Last active July 11, 2025 09:20
Windows 11 Install Script with Winget
@ECHO OFF
echo "Starting installation 🚀"
:: Driver Software
winget install -e --id Nvidia.GeForceExperience
winget install -e --id Logitech.GHUB
winget install -e --id Corsair.iCUE.4
winget install -e --id Nvidia.Broadcast
@dblodgett-usgs
dblodgett-usgs / split_lines.R
Last active January 15, 2025 21:22
Splits lines longer than a given threshold into the minimum number of pieces to all be under the given threshold.
#' @title split lines
#' @description Splits lines longer than a given threshold into the minimum number of pieces to all be under the given threshold.
#' @param lines data.frame of class sf with LINESTRING sfc column.
#' @param max_length maximum segment length to return
#' @param id name of ID column in data.frame
#' @return only the split lines.
#' @importFrom dplyr group_by ungroup filter left_join select rename mutate
#' @export
#'
split_lines <- function(input_lines, max_length, id = "ID") {
@fitnr
fitnr / county-epsg.csv
Last active February 20, 2025 23:24
List of State Plane coordinate systems and their various ID codes.
COUNTYFIPS NAME STATEPLANEFIPS EPSG
16079 Shoshone County 1103 26970
16073 Owyhee County 1103 26970
16071 Oneida County 1101 26968
16077 Power County 1101 26968
16075 Payette County 1103 26970
06115 Yuba County 0402 26942
06111 Ventura County 0405 26945
06113 Yolo County 0402 26942
31177 Washington County 2600 32104