Skip to content

Instantly share code, notes, and snippets.

View dfsnow's full-sized avatar

Dan Snow dfsnow

View GitHub Profile
@dfsnow
dfsnow / pivot.awk
Last active December 4, 2022 03:28
Code to pivot OD matrices from long to wide (via bash pipe/stdin)
# Create an array of columns (destinations) from separate input file
BEGIN {
FS=OFS=","
while ((getline line <dests) > 0) {
contents = contents line
}
numCols = split(contents,cols)
}
# Create the CSV header by printing each destination
@dfsnow
dfsnow / AirGradient_DIY_PRO_V3_7_Prometheus.ino
Last active August 1, 2023 19:16
Arduino sketch to export Prometheus metrics from the AG DIY Pro V3.7, based on Jeff Geerling's code
#include <AirGradient.h>
#include <WiFiManager.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
#include <EEPROM.h>
#include <SensirionI2CSgp41.h>
#include <NOxGasIndexAlgorithm.h>
@dfsnow
dfsnow / obsidian-web-clipper.js
Last active September 15, 2023 05:59 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@dfsnow
dfsnow / gtfs_map_generator.R
Last active January 22, 2024 00:58
Generate animated transit maps using GTFS feeds. See https://sno.ws/transit-maps
##### Setup #####
# Load the necessary libraries
library(tidytransit) # Parse GTFS feeds
library(dplyr)
library(tidyr)
library(lubridate)
library(sf)
library(ggplot2)
library(gganimate) # Animate the ggplot + tween between frames
@dfsnow
dfsnow / json-exporter-config.yaml
Last active April 2, 2024 05:11
Export Jellyfin playback statistics to Prometheus and Grafana. See https://sno.ws/jellyfin-stats for more info
modules:
jellyfin:
headers:
# The Token value here needs to be an API key generated from the
# Jellyfin admin panel. It's hard-coded here but I'm sure there's
# a better way
Authorization: MediaBrowser Token=ADD_TOKEN_HERE
Content-Type: application/json
accept: application/json
@dfsnow
dfsnow / routing_test.R
Created April 22, 2024 00:28
Testing out r5r's routing and travel time matrix functions
# Increase Java memory
options(java.parameters = "-Xmx10G")
# Load libraries
library(data.table)
library(dplyr)
library(ggplot2)
library(ggspatial)
library(osmdata)
library(osmextract)