Skip to content

Instantly share code, notes, and snippets.

View larsyencken's full-sized avatar

Lars Yencken larsyencken

View GitHub Profile
#
# stopwords.txt
#
# Freely available stopword list, balancing coverage and size.
#
# From http://www.lextek.com/manuals/onix/stopwords1.html
a
about
above
across
@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 <tech@ourworldindata.org>"]
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
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 / kml_to_csv.py
Last active November 22, 2022 13:01
Convert a Google Latitude KML dump to a CSV of timestamp, latitude and longitude
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# kml_to_csv.py
#
"""
Convert a KML file to a CSV set of timestamps and locations.
"""
@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')