Skip to content

Instantly share code, notes, and snippets.

Douglas Duhaime duhaime

Block or report user

Report or block duhaime

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View seed data
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
side = 85
n = side * side
xy = np.random.uniform(low=-1, high=+1, size=(n, 2))
xy = np.cumsum(xy, axis=0)
xy -= xy.min(axis=0)
duhaime /
Created Jan 2, 2020 — forked from naught101/
Separating points on a map
def lat_lon_hex_mesh(bounds, d=3):
"""Creates a hexagonal lat/lon mesh within bounds that has a radial separation of d"""
lone, lonw, lats, latn = bounds
# heigt of equilatral triangle from radial distance sqrt(r^2 - (r/2)^2)
h = np.sqrt(0.75) * d
w = d / 2
lat_vals = np.arange(lats, latn, h)
duhaime / index.js
Created Dec 11, 2019
Firebase Cloud Function
View index.js
const functions = require('firebase-functions');
const axios = require('axios');
exports.helloWorld = functions.https.onRequest((request, response) => {
response.set('Access-Control-Allow-Origin', '*');
response.set('Access-Control-Allow-Methods', 'GET, POST');
const url = '';
return axios.get(url)
.then(data => response.status(200).json({
View .gitignore
duhaime /
Last active Oct 20, 2019
Simple ASCII Encoding
import numpy as np
from scipy.misc import imread
from skimage.transform import resize
import matplotlib.pyplot as plt
import json, glob
#%matplotlib inline
def path_to_string(path):
'''Given a path to an image, return a string of that image as ascii'''
duhaime / index.html
Last active Oct 3, 2019
Posenet in the browser
View index.html
<meta charset='UTF-8'>
<script src=''></script>
<script src=''></script>
<script src='' type='text/javascript'></script>
duhaime / index.html
Last active Dec 18, 2019
gunzip js gzip
View index.html
<!DOCTYPE html>
<meta charset='UTF-8'>
<script src='gunzip.min.js'></script>
<script type='text/javascript'>
duhaime /
Created Sep 12, 2019
Keras Image to Vector
from keras.preprocessing.image import load_img, save_img, img_to_array, array_to_img
from keras.applications import Xception, VGG19, InceptionV3, imagenet_utils
import keras.backend as K
import numpy as np
model = Xception(weights='imagenet')
# VGG16, VGG19, and ResNet take 224×224 images; InceptionV3 and Xception take 299×299 inputs
img = load_img('l.jpg', target_size=(299,299))
arr = img_to_array(img)
duhaime /
Last active Sep 11, 2019
smtp python
from flask import Flask, render_template
from smtp_client import send_email
from smtp_server import SMTPServer
app = Flask(__name__)
def email():
server = SMTPServer()
duhaime / OrbitControls.js
Last active Aug 20, 2019
Low-Poly Scene (Three.js)
View OrbitControls.js
* @author qiao /
* @author mrdoob /
* @author alteredq /
* @author WestLangley /
THREE.OrbitControls = function ( object, domElement ) {
this.object = object;
You can’t perform that action at this time.