Skip to content

Instantly share code, notes, and snippets.

View sharonhoward's full-sized avatar

Sharon Howard sharonhoward

View GitHub Profile
@chriscarrollsmith
chriscarrollsmith / llm-hackathon-submissions.md
Last active July 18, 2025 08:29
Writeup of submissions to the Coders' Colaboratory `llm` hackathon in Latham, New York

Projects

Runner-Up: Doctor of Credit

Prerequisites

Google Chrome CLI entrypoint

@pletcher
pletcher / prog-hist-word-freq.py
Created March 11, 2025 18:47
A rewrite of the Programming Historian Word Frequencies lesson to use the Old Bailey API instead of requesting the web page
#html-to-freq.py
# original lesson: https://programminghistorian.org/en/lessons/counting-frequencies
# We've added json to the list of imports — you don't need to install anything,
# json is part of the Python standard library.
import urllib.request, urllib.error, urllib.parse, json, obo
# Notice that instead of requesting the HTML directly, we're now
# making a request to the backend API — meaning a server that returns
# ------------------------------------------------------------------------------------------
# Basically all translated from the Python example at https://atproto.com/blog/create-post
# ------------------------------------------------------------------------------------------
library(httr2)
# Create a logged-in API session object
session <- request("https://bsky.social/xrpc/com.atproto.server.createSession") |>
req_method("POST") |>
req_body_json(list(
library(tidyverse)
library(tidytext)
library(gutenbergr)
library(cleanNLP)
little_women_raw <- gutenberg_download(514, meta_fields = "title")
little_women <- little_women_raw %>%
slice(70:n()) %>%
mutate(chapter_start = str_detect(text, "^CHAPTER"),
@nuest
nuest / switching-from-XML-to-xml2.md
Last active May 10, 2025 09:37
Switching an R package from XML to xml2

Switching from XML to xml2

Rationale

The R package XML for parsing and manipulation of XML documents in R is not actively maintained anymore, but used by many:

The R package xml2 is an actively maintained, more recent alternative.

This file documents useful resources and steps for moving from XML to xml2.

# Takes an ordered vector of numeric values and returns a small bar chart made
# out of Unicode block elements. Works well inside dplyr mutate() or summarise()
# calls on grouped data frames.
sparkbar <- function(values) {
span <- max(values) - min(values)
if(span > 0 & !is.na(span)) {
steps <- round(values / (span / 7))
blocks <- c('', '', '', '', '', '', '', '')
paste(sapply(steps - (min(steps) - 1), function(i) blocks[i]), collapse = '')
@mhbeals
mhbeals / paperspast_all.py
Last active April 18, 2018 00:55
A script to download all (as of April 2018) newspaper articles from Papers Past (NZ)
import requests
number = 1
# Note, this will take a long time!
while number < 1318493:
# Make sure to change your API key at the end of the URL
urltext = "http://api.digitalnz.org/v3/records.xml?api_key=################&and[collection][]=Papers+Past&sort=date&text=+&and[category][]=Newspapers&direction=asc&page=" + str(number)
@colbenkharrl
colbenkharrl / Filtering Nodes
Last active November 22, 2024 13:06
Filtering Nodes on Force-Directed Graphs (D3 V4)
Click to view more!
@ramhiser
ramhiser / stratify.r
Last active April 1, 2021 14:22
Stratified Sampling in R with dplyr
# Uses a subset of the Iris data set with different proportions of the Species factor
set.seed(42)
iris_subset <- iris[c(1:50, 51:80, 101:120), ]
stratified_sample <- iris_subset %>%
group_by(Species) %>%
mutate(num_rows=n()) %>%
sample_frac(0.4, weight=num_rows) %>%
ungroup