Skip to content

Instantly share code, notes, and snippets.

View kylebarron's full-sized avatar

Kyle Barron kylebarron

View GitHub Profile
@kylebarron
kylebarron / orucase.py
Created September 28, 2021 01:12
Average of orucase reviews
import requests
import re
# Airport ninja
# product_id = '163194625'
# n_pages = 63
# B2
product_id = '3776320176181'
n_pages = 17
@kylebarron
kylebarron / demo.ipynb
Last active April 12, 2021 23:15
Test binder from Gist
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebarron
kylebarron / sentinel-2-l2a-mosaic-120-2019-12-7-01K.json
Last active February 10, 2021 06:49
Scratch work for creating STAC items for Sentinel-2 L2A 120m Mosaic (https://registry.opendata.aws/sentinel-s2-l2a-mosaic-120/)
{
"type": "Feature",
"stac_version": "1.0.0-beta.2",
"id": "sentinel-2-l2a-mosaic-120-2019-12-7-01K",
"properties": {
"start_datetime": "2019-12-07T00:00:00",
"end_datetime": "2019-12-17T00:00:00",
"platform": "sentinel-2",
"gsd": 120,
"datetime": null
@kylebarron
kylebarron / pyproject.toml
Created November 4, 2020 19:49
Example pyproject.toml for poetry issue "BadZipFile with public pypi package"
[tool.poetry]
name = "tmp"
version = "0.1.0"
description = ""
authors = ["Kyle Barron"]
[tool.poetry.dependencies]
python = "^3.7"
pyarrow = "^2.0.0"
@kylebarron
kylebarron / pack-12bits-sentinel.py
Created September 15, 2020 00:45
Example of packing bits for sentinel data
import zlib
from io import BytesIO
# pip install bitstruct
import bitstruct
import numpy as np
import rasterio
path = 's3://sentinel-cogs/sentinel-s2-l2a-cogs/2020/S2A_26PQB_20200401_0_L2A/B02.tif'
@kylebarron
kylebarron / pack-12bits.py
Created September 14, 2020 23:48
Pack 12-bit buffer (very inefficient right now)
import zlib
from io import BytesIO
# pip install bitstruct
import bitstruct
import numpy as np
arr = np.random.randint(0, 4096, size=(256, 256), dtype=np.uint16)
buf = BytesIO()
np.save(buf, arr)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebarron
kylebarron / affine_reproj_tile_intersect.py
Last active March 25, 2020 20:01
Source-tile intersection queries using Affine projection matrices
def intersect_bounds(bounds1, bounds2):
"""Find intersection of two bounding boxes
Attributes
----------
bounds1 : list
bounds (left, bottom, right, top).
bounds2 : list
bounds (left, bottom, right, top).
Returns
-------
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylebarron
kylebarron / new_droplet.md
Last active October 6, 2019 19:56
Starter code for new DO droplet
  1. Log on with ssh root@<public ip>.
  2. Add new user with adduser <username>.
  3. Give that new user sudo permissions with usermod -aG sudo <username>
  4. Copy ssh keys from root user to new user
    mkdir /home/<username>/.ssh
    cp ~/.ssh/authorized_keys /home/<username>/.ssh/
    chown <username> /home/<username>/.ssh/authorized_keys
    
  5. Log out and log on with that new user ssh <username>@<public ip>