Skip to content

Instantly share code, notes, and snippets.

View Seagor's full-sized avatar

Sean Gorman Seagor

View GitHub Profile
#!/bin/sh
"exec" "twxec" "-e" "rand_ints()" "$0" "$@"
import random
import gevent
def rand_ints():
while True:
value = random.randint({{number minval}}, {{number maxval}} + 1)
@Seagor
Seagor / webmap.json
Created November 18, 2015 16:36
Census Blocks
{
"item": {
"title": "New Map",
"snippet": "Census Blocks",
"extent": [
[
-124.86249999996639,
-42.233197141816774
],
[
@Seagor
Seagor / index.html
Last active December 1, 2015 14:53
Twitter Data Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href=
"http://js.arcgis.com/3.14/esri/css/esri.css">
<link rel="stylesheet" type="text/css" href=
"https://rawgit.com/benheb/legend/master/legend.css">
%matplotlib inline
import matplotlib.pyplot as plt
from datetime import timedelta
from bson import ObjectId
import seaborn as sns
sns.set_style('whitegrid')
from itertools import cycle
cyclic_palette = cycle(sns.color_palette())
values = []
X = [ObjectId(oid).generation_time for oid, rec in data][:40]
import base64 as b64
import numpy as np
import cv2
import matplotlib.pyplot as plt
from ipywidgets import interact, interactive, fixed
from IPython.display import Image, display
import ipywidgets as widgets
def convert_media_to_image(media):
arr = np.asarray(bytearray(b64.b64decode(media["__data__"])), dtype=np.uint8)
@Seagor
Seagor / image_scraper.py
Last active April 7, 2016 02:30
A scraper for fetching images from a webcam
import gevent
import urllib2
image_url = "http://manage.hdrelay.com/snapshot/ee489921-1004-45df-9634-0fa96543dabf?size=710x425&f=30000"
polling_interval = "31"
def stream():
while True:
msg = {"media_url": image_url}
msg["polling_interval"] = float(polling_interval)
import os
import rasterio
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def render_array(arr1, arr2=None, width=7, height=7, cmap=plt.cm.jet):
if arr2 is None:
fig, ax = plt.subplots(1, figsize=(width,height), facecolor='white')
import gevent
from planet import api
import geojson
bbox = {{ string bbox }}
minx, miny, maxx, maxy = None, None, None, None
if bbox is not None:
minx, miny, maxx, maxy = bbox.split(',')
if minx is not None:
from planet import api
import sys, os
import urllib2, httplib
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
class NoRedirection(urllib2.HTTPErrorProcessor):
def http_response(self, request, response):
import numpy as np
import cv2
from skimage import measure
from skimage.measure import regionprops
from skimage.morphology import skeletonize, convex_hull_image, medial_axis, opening
from scipy import ndimage
def seg_buffer(im, dist=25):
mask = im.copy()