Skip to content

Instantly share code, notes, and snippets.

Avatar

Douglas Duhaime duhaime

View GitHub Profile
@duhaime
duhaime / index.html
Last active May 27, 2023 17:19
Three.js points mesh + ShaderMaterial
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>title</title>
<style>
body, html {
margin: 0;
padding: 0;
background: #000;
@duhaime
duhaime / body2mesh.js
Last active May 25, 2023 19:48
Convert a Cannon.js body to a THREE.js mesh
View body2mesh.js
function body2mesh(body, wireframe) {
var wireframe = wireframe || true;
var obj = new THREE.Object3D();
for (var l = 0; l < body.shapes.length; l++) {
var shape = body.shapes[l];
var mesh;
switch(shape.type){
@duhaime
duhaime / index.html
Last active April 20, 2023 10:00
Three.js: Indexed Buffer Geometry with Texture and Custom Shader Attributes
View index.html
<html>
<head>
<style>
html, body { width: 100%; height: 100%; background: #000; }
body { margin: 0; overflow: hidden; }
canvas { width: 100%; height: 100%; }
</style>
</head>
<body>
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/92/three.min.js'></script>
@duhaime
duhaime / measure_img_similarity.py
Last active March 1, 2023 08:41
Compare image similarity in Python using Structural Similarity, Pixel Comparisons, Wasserstein Distance (Earth Mover's Distance), and SIFT
View measure_img_similarity.py
import warnings
from skimage.measure import compare_ssim
from skimage.transform import resize
from scipy.stats import wasserstein_distance
from scipy.misc import imsave
from scipy.ndimage import imread
import numpy as np
import cv2
##
@duhaime
duhaime / headless.py
Last active February 16, 2023 23:19
Python Selenium Headless Chrome OSX
View headless.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', chrome_options=chrome_options)
driver.get("http://www.duo.com")
@duhaime
duhaime / doors-ice.jpg
Last active January 28, 2023 21:33
Three.js Image Overlay
@duhaime
duhaime / TrackballControls.js
Created May 12, 2019 15:29
Image Pixels (Three.js)
View TrackballControls.js
/**
* @author Eberhard Graether / http://egraether.com/
* @author Mark Lundin / http://mark-lundin.com
* @author Simone Manini / http://daron1337.github.io
* @author Luca Antiga / http://lantiga.github.io
*/
THREE.TrackballControls = function ( object, domElement ) {
var _this = this;
@duhaime
duhaime / arrowhead.js
Created September 17, 2017 13:28
Directed Graph Arrowhead
View arrowhead.js
// Add svg marker for arrowheads
svg.append('svg:defs').append('svg:marker')
.attr('id', 'arrowhead')
.attr('viewBox', '0 0 10 10')
.attr('refX', 22)
.attr('refY', 5)
.attr('markerWidth', 9)
.attr('markerHeight', 9)
.attr('orient', 'auto')
.append('svg:path')
@duhaime
duhaime / .gitignore
Last active July 12, 2022 16:22
Minimal Multiple File Uploads with Vue + Node or Flask Server
View .gitignore
*.pem
*.swp
*.DS_Store
__pycache__/
node_modules/
uploaded_files/
@duhaime
duhaime / .gitignore
Last active July 6, 2022 15:23
Minimal Heroku / Flask App
View .gitignore
*.pyc
__pycache__