Skip to content

Instantly share code, notes, and snippets.

View adriangb's full-sized avatar

Adrian Garcia Badaracco adriangb

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.
@adriangb
adriangb / binary_index_tree.py
Created March 28, 2020 17:26
Binary index tree (Fenwick tree) implemented in Python as a wrapper for lists
class BinaryIndexTree(list):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._tree = list()
self._rebuild_tree()
@staticmethod
def _lowest_one_bit(i):
return i & -i
import random
from geopandas import GeoDataFrame, GeoSeries, sjoin
from shapely.geometry import Point, LineString, Polygon
import numpy as np
class BenchPredicates:
param_names = ["predicate"]
name: Deploy Docs
on:
workflow_run:
workflows:
- Build Docs
types:
- completed
jobs:
deploy:
name: Build Docs
on:
push:
branches:
- main
- develop
pull_request:
release:
types:
- published
"""This script is run from docs_deploy.yml
It writes JSON like this:
{"latest": "refs/heads/main"}
To a file called versions.json at the root
of the docs branch.
It will also update index.html to point to the
exclude: ['_config.yml', '*.py']
include: ['_*', 'versions.json']
@adriangb
adriangb / bench.py
Last active February 21, 2021 19:46
SaveModel vs. Pickle (via SaveModel)
import tempfile
from timeit import default_timer, timeit
from typing import List, Tuple
from matplotlib import pyplot as plt
import numpy as np
from tensorflow import keras
from tensorflow.keras.models import load_model
from scikeras._saving_utils import pack_keras_model
import asyncio
import contextvars
ctxvar = contextvars.ContextVar("ctx")
async def lifespan():
ctxvar.set("spam")
return contextvars.copy_context()
async def endpoint():
import asyncio
from contextlib import asynccontextmanager
import contextvars
ctxvar = contextvars.ContextVar("ctx")
@asynccontextmanager
async def lifespan():
ctxvar.set("spam")
yield