Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
@duhaime
duhaime / download.py
Created April 12, 2020 13:20
Download Unsplash Images
import os, requests, json
q = 'recipe'
p = 0
imgs = []
out_dir = 'fetched-images'
if not os.path.exists(out_dir): os.makedirs(out_dir)
while True:
@duhaime
duhaime / dates-to-stacked-barchart.ipynb
Last active March 26, 2020 14:23
dates to stacked barchart
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duhaime
duhaime / index.html
Last active June 18, 2020 12:11
minimal three.js scene
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<style>* {margin: 0; padding: 0; height: 100%; width: 100%;}</style>
</head>
<body>
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/110/three.min.js'></script>
<script>
var scene = new THREE.Scene();
@duhaime
duhaime / zoom.js
Created March 3, 2020 21:44
Zoom to cursor
controls.noZoom = true;
window.addEventListener('mousewheel', function(e) {
e.preventDefault();
var x = ( event.clientX / window.innerWidth ) * 2 - 1,
y = - ( event.clientY / window.innerHeight ) * 2 + 1,
vector = new THREE.Vector3(x, y, 1),
factor = 0.005,
func = e.deltaY < 0 ? 'addVectors' : 'subVectors';
vector.unproject(camera);
@duhaime
duhaime / .gitignore
Last active July 29, 2024 01:24
Points Scale Testing
.ipynb_checkpoints
*.pyc
*.pem
*.swp
*.json
*.DS_Store
@duhaime
duhaime / cluster.ipynb
Created February 7, 2020 20:01
hdbscan clustering parameters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@duhaime
duhaime / conditional-gan.png
Last active February 6, 2020 18:34
Ruscha Experiments
conditional-gan.png
/**
* Loads a Wavefront .mtl file specifying materials
*
* @author angelxuanchang
*/
THREE.MTLLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
@duhaime
duhaime / seed data
Created January 7, 2020 20:43
seed data 2d
%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 January 2, 2020 17:37 — forked from naught101/separate_points.py
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)