Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
@duhaime
duhaime / index.js
Created December 11, 2019 03:28
Firebase Cloud Function
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,
@duhaime
duhaime / .gitignore
Last active January 5, 2021 20:41
minhash
matches
ngrams
*.swp
*.pem
*.json
@duhaime
duhaime / encode.py
Last active June 18, 2020 12:10
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
duhaime / index.html
Last active June 18, 2020 12:09
Posenet in the browser
<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/[email protected]/dist/ml5.min.js' type='text/javascript'></script>
</head>
<body>
@duhaime
duhaime / example.html
Last active June 18, 2020 12:06
gunzip js gzip
<!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 September 12, 2019 19:01
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
duhaime / app.py
Last active June 27, 2023 16:16
smtp python
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 August 20, 2019 12:24
Low-Poly Scene (Three.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;
@duhaime
duhaime / plot-bunnies.ipynb
Last active August 1, 2019 17:44
plot-bunnies.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duhaime
duhaime / dither.ipynb
Created July 30, 2019 14:04
Floyd-Steinberg Dithering
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.