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
np.random.seed(0)
xy = np.random.uniform(low=-1, high=+1, size=(n, 2))
xy = np.cumsum(xy, axis=0)
xy -= xy.min(axis=0)
@duhaime
duhaime / separate_points.py
Created Jan 2, 2020 — forked from naught101/separate_points.py
Separating points on a map
View separate_points.py
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
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 = 'https://travel-birds-app.firebaseio.com/users/9b74fd7a-1a2b-11ea-9b18-f45c89b66fa9.json';
return axios.get(url)
.then(data => response.status(200).json({
message: data.data,
View .gitignore
matches
ngrams
*.swp
*.pem
*.json
@duhaime
duhaime / encode.py
Last active Oct 20, 2019
Simple ASCII Encoding
View encode.py
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
duhaime / index.html
Last active Oct 3, 2019
Posenet in the browser
View index.html
<html>
<head>
<meta charset='UTF-8'>
<title>PoseNet</title>
<script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/p5.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.8.0/addons/p5.dom.min.js'></script>
<script src='https://unpkg.com/ml5@0.3.1/dist/ml5.min.js' type='text/javascript'></script>
</head>
<body>
@duhaime
duhaime / index.html
Last active Dec 18, 2019
gunzip js gzip
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>title</title>
</head>
<body></body>
<script src='gunzip.min.js'></script>
<script type='text/javascript'>
@duhaime
duhaime / vectorize_image.py
Created Sep 12, 2019
Keras Image to Vector
View vectorize_image.py
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
duhaime / app.py
Last active Sep 11, 2019
smtp python
View app.py
from flask import Flask, render_template
from smtp_client import send_email
from smtp_server import SMTPServer
app = Flask(__name__)
@app.route('/send_email')
def email():
server = SMTPServer()
server.start()
@duhaime
duhaime / OrbitControls.js
Last active Aug 20, 2019
Low-Poly Scene (Three.js)
View OrbitControls.js
/**
* @author qiao / https://github.com/qiao
* @author mrdoob / http://mrdoob.com
* @author alteredq / http://alteredqualia.com/
* @author WestLangley / http://github.com/WestLangley
*/
THREE.OrbitControls = function ( object, domElement ) {
this.object = object;
You can’t perform that action at this time.