Skip to content

Instantly share code, notes, and snippets.

@tallcoleman
tallcoleman / bicycle_parking_overpass.r
Last active February 9, 2025 03:19
Directly query bike parking features in OpenStreetMap
# Example of querying amenity=bicycle_parking using direct overpass query in r
# Limiting output based on existing area from Overpass API
# Documentation - see:
# https://docs.ropensci.org/osmdata/articles/osmdata.html#extracting-osm-data-from-a-query
# https://docs.ropensci.org/osmdata/reference/osmdata_sf.html
# set up packages
install.packages("osmdata")
install.packages("glue")
/*
* Script to pull live data from BikeSpace API into Google sheets
* To use, set a time trigger (e.g. to run importData every hour)
*
* For first time set up, you may want to set a trigger to run every 5 minutes
* (Every minute is too frequent; starts pulling duplicate data)
* Then let the trigger run for about an hour
*/
// config
@tallcoleman
tallcoleman / Intersect.gs
Last active June 12, 2025 12:31
Intersect() function for Google Apps Script
/**
* Returns the intersection of two ranges, or null if there is no overlap.
* @param {SpreadsheetApp.Range} r1 Range 1
* @param {SpreadsheetApp.Range} r2 Range 2
* @returns {SpreadsheetApp.Range}
*/
function Intersect(r1, r2) {
if (r1.getSheet().getSheetId() !== r2.getSheet().getSheetId()) return null;
const FIRSTROW = Math.max(r1.getRow(), r2.getRow());
@tallcoleman
tallcoleman / check_youtube_playlist_videos.gs
Last active November 26, 2024 09:28
Youtube playlists - email notification when new videos are posted
// INSTRUCTIONS
// 1. Go to https://script.google.com/ and make a new project
// (optional: rename it too, so you remember what it is later...)
// 2. Paste in this script and add your email and playlist IDs below (see note [1])
// 3. Save the script and do a test run to set up the permissions
// 4. Set up a trigger to run the check_playlists_youtube function every day
function check_playlists_youtube() {
// OPTIONS: specify playlists to check and email to notify
const PLAYLISTS = {
/*
Sorry Counter
=============
Instructions:
- go to script.google.com
- new project
- paste this in, save, select "run"
- give the script permissions to search your email
- enjoy learning how apologetic you are