Skip to content

Instantly share code, notes, and snippets.

View larsyencken's full-sized avatar

Lars Yencken larsyencken

View GitHub Profile
@larsyencken
larsyencken / pyproject.toml
Created June 28, 2023 10:43
OWID: pyproject.toml example for poetry issue
[tool.poetry]
name = "owid-datautils"
version = "0.5.3"
description = "Data utils library by the Data Team at Our World in Data"
authors = ["Our World In Data <[email protected]>"]
license = "MIT"
packages = [{ include = "owid" }]
readme = "README.md"
repository = "https://github.com/owid/owid-datautils-py"
homepage = "https://github.com/owid/owid-datautils-py"
@larsyencken
larsyencken / 2023-06-26 Plain Jupyter display.ipynb
Last active June 26, 2023 23:32
OWID: plain vs rich catalog display
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@larsyencken
larsyencken / config.nu
Last active June 16, 2023 09:36
Nushell: detect Python and Node environments
# just a partial config, only look at env_change
{
hooks: {
env_change: {
PWD: [
{
# if you enter a python project
condition: {|before, after| ["pyproject.toml" "requirements.txt"] | any {|f| $f | path exists } }
# drop any prior virtualenv, then use a new one if it exists
code: "
@larsyencken
larsyencken / README.md
Created June 5, 2023 11:03
Nushell: MySQL access

MySQL in Nushell

Here are some helpers for using MySQL in Nushell. You need the MySQL client installed, and also the separate MySQL Shell client (for JSON output).

The mysql-profile command is an optional helper for keeping multiple MySQL connection profiles around in your ~/.my.cnf and switching between them, instead of having to give credentials every time.

Enjoy!

@larsyencken
larsyencken / dependencies.md
Last active December 21, 2022 04:52
OWID: dependencies between libraries

Current dependencies

graph LR

etl --> owid-catalog-py
etl --> walden --> owid-datautils-py
walden --> owid-catalog-py
etl --> owid-datautils-py
@larsyencken
larsyencken / .zshrc
Created September 15, 2022 12:13
zsh: auto-enter python virtualenvs on cd
#
# python: enter virtualenv on chpwd
#
load-py-venv() {
if [ -f .venv/bin/activate ]; then
# enter a virtual environment that's here
source .venv/bin/activate
elif [ -f env/bin/activate ]; then
source env/bin/activate
elif [ ! -z "$VIRTUAL_ENV" ] && [ -f pyproject.toml -o -f requirements.txt ]; then
@larsyencken
larsyencken / mysql-profile
Created September 7, 2022 12:12
MySQL: use the ~/.my.cnf file to store multiple connection settings and use this tool to switch between them
#!/usr/bin/env python
#
# mysql-profile
#
# Switch between mysql profiles.
#
from pathlib import Path
import configparser
from dataclasses import dataclass
@larsyencken
larsyencken / example.py
Created July 29, 2022 07:48
Python: isolate a function in a separate process
from concurrent.futures import ProcessPoolExecutor
def dog():
raise ValueError('not a dog, a cat')
def main():
try:
with ProcessPoolExecutor(1) as executor:
executor.submit(dog).result()
print('no exception')
@larsyencken
larsyencken / etl_prod.md
Last active July 27, 2022 15:43
OWID: data deployment via the ETL
sequenceDiagram
    participant cron
    participant etl_prod
    participant bulk_backport
    participant walden
    participant etl
    participant disk
    participant s3
    participant github
@larsyencken
larsyencken / shui-hu-zhuan-heroes.txt
Created May 4, 2022 13:17
A partial list of heros from "Water Margin" (c. 1350 AD) a.k.a. "Outlaws of the Marsh"
Arrow−Struck Tiger
Big Halberd
Black Whirlwind
Boat Flame
Comet
Demon Carver
Demon Face
Demon King Who Roils the World
Dragon from the Cave
Dragon from the Forest