Skip to content

Instantly share code, notes, and snippets.

View kleinlennart's full-sized avatar
💭

Lennart Klein kleinlennart

💭
View GitHub Profile
@kleinlennart
kleinlennart / structured_output_prompt.py
Last active February 28, 2025 18:19
Snippet for Structured Output Prompt OpenAI API, Loop over DataFrame
import json
from pathlib import Path
import pandas as pd
from dotenv import load_dotenv
from openai import OpenAI
from tqdm import tqdm
# .env
# OPENAI_API_KEY=<API-Key>
@kleinlennart
kleinlennart / scraping_executive_orders.py
Created January 21, 2025 17:36
Web Scraping Trump II Presidential Actions / Executive Orders from Whitehouse.gov
import requests
from bs4 import BeautifulSoup
import pandas as pd
actions = []
# FIXME: update page limit
for page in range(1, 6):
url = f"https://www.whitehouse.gov/presidential-actions/page/{page}/"
@kleinlennart
kleinlennart / ggplot2_map.R
Created January 9, 2025 21:30
Data Visualization Snippets | World Map with Country Dots
library(tidyverse)
library(sf)
# Data --------------------------------------------------------------------
raw_survey <- read_csv(here::here("data", "input", "Survey", "Crisis+Data+Ecosystem+Survey_RAW.csv"))
# Wrangle -----------------------------------------------------------------
# remove the variable descriptions row, only useful for new colnames
@kleinlennart
kleinlennart / snippets.R
Created January 8, 2025 19:09
RStudio Snippets
snippet pak
pak::pak("${1}")
@kleinlennart
kleinlennart / zotero_remove_eprint_extra.ipynb
Created May 26, 2024 17:56
zotero_remove_eprint_extra.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kleinlennart
kleinlennart / .quartoignore
Created January 16, 2024 15:25
.quartoignore Recommended Defaults for Quarto Extensions
template.Rproj
template.html
*_files/
*_cache/

Lennart's Dotfiles

GitHub Gist last commit

@kleinlennart
kleinlennart / .Rprofile
Last active January 29, 2024 09:23
.Rprofile
if (interactive()) {
suppressMessages(require(usethis))
}
if (interactive()) {
suppressMessages(require(devtools))
}
if (interactive()) {
suppressMessages(require(cput))
@kleinlennart
kleinlennart / markdown.md
Created February 17, 2021 19:10
Markdown Snippets
expand stuff