Skip to content

Instantly share code, notes, and snippets.

View leifdenby's full-sized avatar
🌍

Leif Denby leifdenby

🌍
View GitHub Profile
@leifdenby
leifdenby / ecmwf-event-parser.py
Last active December 1, 2022 09:55
Parser for ECWMF event pages
import requests
import bs4
import dateutil.parser
import pandas as pd
def parse_event_details(url):
"""
Parse event details from ECMWF event page and return title, timings,
speaker name, speaker affiliation, talk pdf and video URLs as a
pandas.DataFrame
@leifdenby
leifdenby / formattedSkimNotes.scpt
Created June 28, 2021 07:20
applescript for Skim annotations export
tell application "Skim"
set theFile to the file of the front document
set outText to ""
set newLine to ASCII character 10
set docTitle to "## Detailed notes"
# This used the commandline tool pdftk to figure out where the table of
@leifdenby
leifdenby / cmip6.py
Last active May 24, 2021 12:22
Example CMIP load from JASMIN
"""
Utility functions for contructing paths and finding files for CMIP6 data
Leif Denby, v3, 24/5/2021
Historical runs (1850-2014) are in
`<data_root>/CMIP/<institute>/<model>/historical/<variant>/<table_id>/<variable>/<grid>/<version>/`
Scenario runs are in
@leifdenby
leifdenby / generic_consumer_task.py
Created March 29, 2021 09:35
Consumer task with dynamic number of requirements
import luigi
def pack(cls, **kwargs):
return dict(class_name=cls.__name__, kwargs=kwargs)
def unpack(class_name, kwargs):
TaskClass = globals()[class_name]
return TaskClass(**kwargs)
@leifdenby
leifdenby / build.sh
Last active February 2, 2021 18:10
Building vim with python3 support against conda python (into ~/.local)
# create a conda environment with python3 and activate it
git clone https://github.com/vim/vim
cd vim
./configure --with-features=huge --enable-python3interp=dynamic --prefix=$HOME/.local
# add the following lines to ~/.vimrc, changing `py36` do your env name and possible the python version in `libpython3.7m.so`
#
# set pythonthreedll=$HOME/anaconda2/envs/py37/lib/libpython3.7m.so
# set pythonthreehome=$HOME/anaconda2/envs/py37/
@leifdenby
leifdenby / httpcors
Created January 16, 2021 13:13 — forked from gkatsev/httpcors
simple python3 http server with CORS enabled
#!/usr/bin/env python
import http.server
class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
@leifdenby
leifdenby / filter_bibliography.py
Created June 10, 2020 09:47
Filter bibliography file based on citations used in tex document
# coding: utf-8
"""
Created a filtered .bib-file from citations used in a specific .tex source file
"""
import pybtex
import pybtex.database
import pybtex.errors
import re
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leifdenby
leifdenby / taskchain.sh
Created November 6, 2018 14:31
Utility for chaining multiple dependent PBS submit scripts
# Utility function for chaining multiple PBS submit scripts
# Leif Denby 6/11/2018
#
# usage:
#
# 1. Create a file containing the individual steps, e.g.
#
# tasklist.sh:
# WALLCLOCK=00:15:00 ./run.sh example_run
# WALLCLOCK=00:15:00 ./run.sh analysis
@leifdenby
leifdenby / notebook.ipynb
Created July 13, 2018 09:49
xESMF - Input array is not F_CONTIGUOUS issue
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.