Skip to content

Instantly share code, notes, and snippets.

View r-leyshon's full-sized avatar

Richard Leyshon r-leyshon

  • Office for National Statistics Data Science Campus
  • Wales, United Kingdom
View GitHub Profile
@r-leyshon
r-leyshon / actions-workflow.yml
Created April 19, 2024 12:36
Breaking changes to codecov-action means CODECOV_TOKEN needs to be set on open repos.
name: API workflow
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
name: Test python API
steps:
- name: Checkout
@r-leyshon
r-leyshon / batch-add.py
Created April 16, 2024 06:00
Add a group of collaborators to a repository
import warnings
import requests
import toml
from pyprojroot import here
CONFIG = toml.load(here("secrets.toml"))
AGENT = CONFIG["USER"]["AGENT"]
USERS = CONFIG["GITHUB"]["USERNAMES"]
PAT = CONFIG["GITHUB"]["PAT"]
@r-leyshon
r-leyshon / get_data.py
Created December 15, 2023 10:11
Ingest all UK LSOA21 boundaries from ONS Geoportal
import requests
import geopandas as gpd
import pandas as pd
ENDPOINT = "https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/"
"Lower_layer_Super_Output_Areas_2021_EW_BFC_V8/FeatureServer/0/query"
params = {
"where": "1=1", # SQL clauses can go here
"outSR": 4326, # CRS that you want
@r-leyshon
r-leyshon / render_toc.R
Created August 10, 2021 06:16 — forked from gadenbuie/render_toc.R
Generate Manual Table of Contents in (R)Markdown Documents
#' Render Table of Contents
#'
#' A simple function to extract headers from an RMarkdown or Markdown document
#' and build a table of contents. Returns a markdown list with links to the
#' headers using
#' [pandoc header identifiers](http://pandoc.org/MANUAL.html#header-identifiers).
#'
#' WARNING: This function only works with hash-tag headers.
#'
#' Because this function returns only the markdown list, the header for the