Skip to content

Instantly share code, notes, and snippets.

View khaeru's full-sized avatar

Paul Natsuo Kishimoto khaeru

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@khaeru
khaeru / discoverable-data-ipcc.ipynb
Last active November 3, 2024 11:04
Discoverable Data for IPCC AR7 WGIII
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@khaeru
khaeru / pandas_parquet_in_blob.py
Last active March 13, 2024 15:36
Store pandas data in an SQL(ite) BLOB field using the Parquet format
"""Store pandas data in an SQL(ite) BLOB field using the Parquet format.
© 2024 Paul Natsuo Kishimoto <[email protected]>.
Licensed under the GNU GPL v3 https://www.gnu.org/licenses/gpl-3.0.en.html.
"""
import sqlite3
from dataclasses import dataclass
from io import BytesIO
@khaeru
khaeru / variables-AR6.txt
Created May 13, 2020 12:49
Transport-related variables in the IPCC AR5 WGIII data template
Capacity|Transportation|Aviation|Freight
Capacity|Transportation|Aviation|Passenger
Capacity|Transportation|Maritime|Freight
Capacity|Transportation|Maritime|Passenger
Capacity|Transportation|Rail|Freight
Capacity|Transportation|Rail|Passenger
Capacity|Transportation|Road|Freight
Capacity|Transportation|Road|Passenger
Discount rate|Economy
Discount rate|Electricity
@khaeru
khaeru / inline.py
Last active October 14, 2019 18:36
Copy inline documentation to Sphinx source tree
"""Crude Sphinx extension for inline documentation.
© 2019 Paul Natsuo Kishimoto <[email protected]>
Licensed under the GNU GPLv3: https://www.gnu.org/licenses/gpl-3.0.html
Star: https://gist.github.com/khaeru/3185679f4dd83b16a0648f6036fb000e
Enable by adding to conf.py::
sys.path.append('path/to/this/file')
extensions.append('inline')
@khaeru
khaeru / dag_reporting.py
Last active February 20, 2019 15:36
Reporting using a directed acyclic graph (DAG)
"""Reporting using a directed acyclic graph (DAG).
2019-01-24 Paul Natsuo Kishimoto <[email protected]>
This is a demo of one possible pattern for a reporting architecture for ixmp
/MESSAGE. It uses a directed acyclic graph (DAG) where the nodes are operations
and edges are data. Calling get(…) on the graph causes a node's output, and all
its dependencies, to be retrieved.
This is implemented using dask:
@khaeru
khaeru / geom_partial.py
Created June 26, 2018 16:18
Like partial(), for plotnine geoms
def geom_partial(name, aes, **geom_kwargs):
"""Like partial(), for plotnine geoms.
*name* refers to a geom, e.g. 'point' for p9.geom_point. *geom_kwargs* are
optional keyword arguments for the geom. *aes* is a dict() with keys that
match the geom's aesthetics, and values that are format strings.
Returns a callable object. When called, the arguments are passed to
str.format() for each entry in *aes*, and a plotnine geom is returned with
the resulting aesthetics and kwargs.
"""Vehicle Acronyms
Usage:
1. Clone https://github.com/tabatkins/railroad-diagrams
2. Drop this file in.
3. $ python3 acronyms.py
Some sources:
- https://en.wikipedia.org/wiki/Automotive_acronyms_and_abbreviations
- http://www.chicagotribune.com/classified/automotive/