Skip to content

Instantly share code, notes, and snippets.

View duhaime's full-sized avatar

Douglas Duhaime duhaime

View GitHub Profile
@duhaime
duhaime / TrackballControls.js
Created May 12, 2019 15:29
Image Pixels (Three.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
// 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 6, 2022 15:23
Minimal Heroku / Flask App
*.pyc
__pycache__
@duhaime
duhaime / convert.py
Created February 23, 2019 15:33
Particle Dance
import json
l = {}
j = json.load(open('dance.json'))
for body_part in j:
l[body_part] = []
sub = []
for idx in j[body_part]:
val = j[body_part][idx]
{"Aberdare": "Mid Glamorgan", "Aberdeen": "Aberdeenshire", "Aberdovey": "Gwynedd", "Abergavenny": "Gwent", "Abergele": "Clwyd", "Abertillery": "Gwent", "Aberystwyth": "Dyfed", "Abingdon": "Oxfordshire", "Accrington": "Lancashire", "Airdrie": "Lanarkshire", "Alcester": "Warwickshire", "Aldeburgh": "Suffolk", "Alderley Edge": "Cheshire", "Aldershot": "Hampshire", "Alfreton": "Derbyshire", "Alness": "Ross-shire", "Alnwick": "Northumberland", "Alresford": "Hampshire", "Alston": "Cumbria", "Alton": "Hampshire", "Altrincham": "Cheshire", "Ambleside": "Cumbria", "Amersham": "Buckinghamshire", "Amesbury": "Wiltshire", "Ammanford": "Carmarthenshire", "Andover": "Hampshire", "Anstruther": "Fife", "Antrim": "Co Antrim", "Appleby-in-Westmorland": "Cumbria", "Arbroath": "Angus", "Ardrossan": "Ayrshire", "Armagh": "Co Armagh", "Arthog": "Gwynedd", "Arundel": "West Sussex", "Ascot": "Berkshire", "Ashbourne": "Derbyshire", "Ashburton": "Devon", "Ashford": "Middlesex", "Ashington": "Northumberland", "Ashtead": "Surrey", "Asht
@duhaime
duhaime / batchProcess.scpt
Last active May 27, 2022 02:07
Batch process files with ABBYY FineReader using AppleScript
-- specify input and output directories
set infile_directory to "/Users/doug/Desktop/inputs/"
set outfile_directory to "/Users/doug/Desktop/outputs/"
-- get the basenames of each input file
tell application "System Events"
set infile_list to files of folder infile_directory
end tell
-- process each input file
@duhaime
duhaime / index.html
Last active May 16, 2022 15:01
Minimal Frame Buffer Object (Three.js)
<html>
<head>
<style>
html, body { width: 100%; height: 100%; background: #000; }
body { margin: 0; overflow: hidden; }
canvas { width: 100%; height: 100%; }
</style>
<meta charset='UTF-8'>
</head>
<body>
@duhaime
duhaime / example.py
Created September 25, 2018 16:27
lloyd's algorithm
import numpy as np
import umap
# generate some points in 4D
points = np.random.random((2000, 4))
# project the points to 2D to get points proximate to one another
points = umap.UMAP().fit_transform(points)
from lloyd.lloyd import Field
@duhaime
duhaime / get_max_texture_size.js
Created April 28, 2018 01:46
Get Max Supported WebGL Texture Size on Host Device
const gl = document.createElement('canvas').getContext('webgl');
console.log(gl.getParameter(gl.MAX_TEXTURE_SIZE))
@duhaime
duhaime / index.html
Last active March 2, 2022 16:56
Minimal Three.js boilerplate
<html>
<head>
<style>
html,
body {
width: 100%;
height: 100%;
background: #000;
}
body {