Skip to content

Instantly share code, notes, and snippets.

@LingDong-
LingDong- / PoissonFill.java
Last active April 13, 2023 07:49
Poisson Filling Shader for Processing(Java)
/* Poisson Filling for Processing
* Made possible with support from The Frank-Ratchye STUDIO For Creative Inquiry
* At Carnegie Mellon University. http://studioforcreativeinquiry.org/
*/
package poissonfill;
import processing.core.*;
import processing.opengl.*;
import java.util.*;
@LingDong-
LingDong- / findcontours.js
Last active April 22, 2024 14:53
Finding contours in binary images and approximating polylines. Implements the same algorithms as OpenCV's findContours and approxPolyDP.
/** Finding contours in binary images and approximating polylines.
* Implements the same algorithms as OpenCV's findContours and approxPolyDP.
* <p>
* Made possible with support from The Frank-Ratchye STUDIO For Creative Inquiry
* At Carnegie Mellon University. http://studioforcreativeinquiry.org/
* @author Lingdong Huang
*/
var FindContours = new function(){let that = this;
let N_PIXEL_NEIGHBOR = 8;
@LingDong-
LingDong- / npy-rw.js
Last active September 29, 2023 08:46
Read and write .npy (numpy) files in javascript
// npy-rw.js
// READ AND WRITE .NPY (NUMPY) FILES
// Lingdong Huang 2019
// npy specs: https://numpy.org/devdocs/reference/generated/numpy.lib.format.html
// reference: https://gist.github.com/nvictus/88b3b5bfe587d32ac1ab519fd0009607
const is_node = (typeof process !== 'undefined')
var npy = {};
@LingDong-
LingDong- / cli-ptcloud.c
Last active December 26, 2019 22:57
cli-ptcloud.c
//
// cli-ptcloud.c
// - Lingdong Huang 2019
//
// View point clouds (.ply format) in commandline
//
// Dependencies:
// - curses (-lcurses, comes with most unix systems)
// - rply (http://w3.impa.br/~diego/software/rply/, place in path below:
#define RPLY_PATH "include/rply/rply.h"
@LingDong-
LingDong- / LaTeX-skin.css
Created October 29, 2018 23:41
Make your HTML look like it's typeset with LaTeX
/*
* LaTeX-skin.css
* (c) Lingdong Huang 2018
* Make your HTML look like it's typeset with LaTeX
*
* Features:
* - LaTeX look and feel, including its font Computer Modern;
* - Automatic numbering of (sub)sections and figures;
* - Print / export to PDF, (On macOS Safari/Chrome, File > Print)
*/
@LingDong-
LingDong- / unmark.js
Created October 29, 2018 22:53
Markdown to HTML in 1 chain of regexes
var unmark = (t)=>(t
//escape tags
.replace(/\\</g,"&lt")
//tables
.replace(/[\n\r^]((((.*\|)+.+)[\n\r$])((\||)((:|)\-+(:|)\|(:|))+\-+(:|)(\||)[\n\r])(((.*\|)+.+)[\n\r$])+)/g,'<p><table>\n$1</table></p>\n')
.replace(/(\||)((:|)\-+(:|)\|(:|))+\-+(:|)(\||)[\n\r](?=((.*[\n\r])*<\/table>))/g,'')
.replace(/(((.*\|)+.+))[\n\r$](?=((.*[\n\r])*<\/table>))/g,' <tr>|$1|</tr>\n')
.replace(/<tr>\|+(.*)\|+<\/tr>/g,'<tr> <td>$1</td> </tr>')
.replace(/\|(?=((.+)<\/tr>))/g,'</td> <td>')
//paragraph