Skip to content

Instantly share code, notes, and snippets.

@tamaracha
tamaracha / youtube-search-scraping.js
Created March 21, 2025 16:55
Scraping YouTube search term completions using Node.js for marketing research
import { writeFile } from 'node:fs/promises'
import { dump } from 'js-yaml'
const getSuggestions = async function (query) {
// https://stackoverflow.com/questions/11275365/youtube-api-search-auto-complete
const endpoint = 'https://clients1.google.com/complete/search?client=youtube&gs_ri=youtube&ds=yt'
const url = new URL(endpoint)
url.searchParams.set('q', query)
const response = await fetch(url)
if (response.ok) {
@tamaracha
tamaracha / tone_audiogram.R
Created June 7, 2020 22:08
How to import printed tone audiograms in R and plot them with ggplot2
library(magrittr)
# Frequencies tested in tone audiograms
audiogram_frequencies <- c(0.125, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4, 6, 8)
# Simulate hearing loss data in wide format
sample_df <- data.frame(
frequency = audiogram_frequencies,
air_right = sample(40:70, size = 11),
air_left = sample(50:90, size = 11),
bone_right = sample(0:30, size = 11),