Skip to content

Instantly share code, notes, and snippets.

View martindurant's full-sized avatar

Martin Durant martindurant

View GitHub Profile
import collections
import dask.array as da
from dask.utils import infer_storage_options
import numpy as np
import pickle
import xarray as xr
import zarr
import dask.dataframe as dd
import gcsfs # registers with dask filesystems
# Initial authentication
# gcs = gcsfs.core.GCSFileSystem(project='continuum-compute',
# token='/Users/mdurant/.config/gcloud/application_default_credentials.json')
# Tiny block-size to ensure more than one block
df = da.read_csv('s3://blaze-data/iris/*', blocksize=2500,
names=['petal_length', 'sepal_length', 'petal_width',
@martindurant
martindurant / gitea.py
Created March 15, 2017 22:24
gitea endpoints
import requests
class GiTea(object):
base_url = 'http://127.0.0.1:3000'
def __init__(self, user, pword, base_url=None):
if base_url is not None:
self.base_url = base_url
@martindurant
martindurant / run.py
Created May 2, 2017 22:38
datashader_by_hand
import dask
import dask.dataframe as dd
import numpy as np
import numba
import time
@numba.njit
def calc_hist(X, Y, xrange, yrange, out, w, h):
x0, x1 = xrange
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@martindurant
martindurant / trace.log
Created July 27, 2017 23:05
example logging
{"time": 1501196547.959372, "log": "start"}
{"finish": "waiting", "log": "transition", "start": "released", "args": [], "time": 1501196559.388243, "key": "<lambda>-c9f069025429b973b33b0f27c23e2347", "kwargs": {}}
{"finish": "processing", "log": "transition", "start": "waiting", "args": [], "time": 1501196559.388446, "key": "<lambda>-c9f069025429b973b33b0f27c23e2347", "kwargs": {}}
{"kwargs": {"client": "Client-a785c5f0-731f-11e7-a5aa-acbc32a9ff1d", "loose_restrictions": [], "dependencies": {"<lambda>-c9f069025429b973b33b0f27c23e2347": []}}, "dsk": null, "keys": ["<lambda>-c9f069025429b973b33b0f27c23e2347"], "log": "update_graph", "restrictions": {}, "time": 1501196559.388531}
{"finish": "memory", "log": "transition", "start": "processing", "args": [], "time": 1501196559.390576, "key": "<lambda>-c9f069025429b973b33b0f27c23e2347", "kwargs": {"startstops": [["compute", 1501196559.391431, 1501196559.3914502]], "thread": 123145409626112, "nbytes": 28, "worker": "tcp://192.168.0.11:58953", "status": "OK"}}
{"finish
@martindurant
martindurant / avro_header.py
Last active November 19, 2021 19:28
How to read an avro header easily
from __future__ import unicode_literals
import json
MAGIC = b'Obj\x01'
SYNC_SIZE = 16
def read_long(fo):
"""variable-length, zig-zag coding."""
c = fo.read(1)
@martindurant
martindurant / forbid
Created December 4, 2017 21:04
Primitive ad-blocker
127.0.0.1 sb.freeskreen.com
127.0.0.1 adfarm.mediaplex.com
127.0.0.1 adclick.g.doubleclick.net
127.0.0.1 secure.insightexpressai.com
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 js.moatads.com
127.0.0.1 cdn.teads.tv
127.0.0.1 s0.2mdn.net
127.0.0.1 ad.doubleclick.net
127.0.0.1 pixel.adsafeprotected.com
@martindurant
martindurant / fuse_test.ipynb
Created February 23, 2018 18:51
GCS FUSE latest
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@martindurant
martindurant / bokeh_tricks.py
Created May 23, 2018 16:31
interactive image
import bokeh
from bokeh.io import output_notebook, push_notebook
output_notebook()
##
import numpy as np
from ipywidgets import interact, widgets
from bokeh.plotting import figure, show