Skip to content

Instantly share code, notes, and snippets.

Avatar
🌎
Mapping

Kyle Barron kylebarron

🌎
Mapping
View GitHub Profile
@kylebarron
kylebarron / pack-12bits-sentinel.py
Created Sep 15, 2020
Example of packing bits for sentinel data
View pack-12bits-sentinel.py
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 Sep 14, 2020
Pack 12-bit buffer (very inefficient right now)
View pack-12bits.py
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)
View widget-deserialization.ipynb
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 Mar 25, 2020
Source-tile intersection queries using Affine projection matrices
View affine_reproj_tile_intersect.py
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
-------
View map.geojson
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 Oct 6, 2019
Starter code for new DO droplet
View new_droplet.md
  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>
@kylebarron
kylebarron / scrape-sitemap.sh
Created Apr 1, 2019 — forked from pix0r/scrape-sitemap.sh
Use wget to scrape all URLs from a sitemap.xml Usage: scrape-sitemap.sh http://domain.com/sitemap.xml
View scrape-sitemap.sh
#!/bin/sh
SITEMAP=$1
if [ "$SITEMAP" = "" ]; then
echo "Usage: $0 http://domain.com/sitemap.xml"
exit 1
fi
XML=`wget -O - --quiet $SITEMAP`
@kylebarron
kylebarron / lvm_personal.md
Created Mar 30, 2019
Using LVM; My Setup
View lvm_personal.md
title date author
Using LVM; My Setup
August 11, 2017
Kyle Barron

TODO: Create personal_backup folder and logical volume on bulk_hdd. This is for non-current tasks which I don't want to have on my NVME.

My Personal LVM Setup

@kylebarron
kylebarron / hn_archive.py
Last active Mar 27, 2019
HN Archiving with ArchiveBox
View hn_archive.py
#! /usr/bin/env python3
import requests
r = requests.get('https://hacker-news.firebaseio.com/v0/topstories.json')
top_ids = r.json()[:40]
url_scrape_list = ['https://news.ycombinator.com']
for hn_id in top_ids:
hn_comment_url = f'https://news.ycombinator.com/item?id={hn_id}'
url_scrape_list.append(hn_comment_url)
@kylebarron
kylebarron / combine_halfmile_gpx.py
Created Feb 14, 2019
Combine Halfmile GPX segments into one or a few big GPX files
View combine_halfmile_gpx.py
#! /usr/bin/env python3
"""
Program: Combine Halfmile GPX tracks into a single GPX track
Author: Kyle Barron
"""
import io
import requests
import gpxpy
import gpxpy.gpx
You can’t perform that action at this time.