Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / hello_world_webgl.js
Last active November 6, 2018 19:38
WebGL Hello World !
window.onload = function () {
// Create the canvas
const canvas = document.createElement('canvas');
canvas.width = canvas.height = 512;
document.body.appendChild(canvas)
const gl = canvas.getContext("webgl");
// Set clear color to black, fully opaque
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
// Create vertex shader
@jdmichaud
jdmichaud / cursor.svg
Created November 8, 2018 16:07
SVG cursor
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jdmichaud
jdmichaud / Box drawing characters
Last active March 3, 2025 13:11
Box drawing characters
https://en.wikipedia.org/wiki/Box-drawing_character
┃┏┓┗┛━
http://xahlee.info/comp/unicode_arrows.html
⯇ ⯈ ⯅ ⯆
◀ ▶ ▲ ▼
Dependency tree
└ ┌ ─ ├
@jdmichaud
jdmichaud / venv.sh
Created December 14, 2018 13:11
Creates a linux virtual environment in .env (using overlayfs and chroot)
#/bin/sh
mkdir .env
mkdir .env/{upper,work,mount}
sudo mount -t overlay -o lowerdir=/,upperdir=.env/upper,workdir=.env/work overlayfs .env/mount
sudo mount -t proc proc .env/mount/proc
sudo mount -t sysfs sys .env/mount/sys
sudo mount -t devtmpfs dev .env/mount/dev
# Needed for tty
sudo mount --bind /dev/pts .env/mount/dev/pts
{
"A": {
"0.1.2": {
"C": "~0.1.0",
"B": "~0.2.0"
},
"0.1.0": {
"C": "~0.1.0",
"B": "~0.1.0"
},
@jdmichaud
jdmichaud / mirror-github-gitlab.sh
Created May 4, 2019 12:18
Script to mirror public projects from github to gitlab
#!/bin/bash
# Usage: ./mirror-github-gitlab.sh
# The script will attempt to create all the projets. If some projects were already mirrored
# gitlab will return an error and the script will just ignore it.
GITHUB_URL=https://github.com
GITLAB_URL=https://gitlab.com
CURLCMD='curl --silent --show-error'
@jdmichaud
jdmichaud / newton.js
Last active May 23, 2019 16:55
Newton's method
// Newton's method as explained here: https://youtu.be/U0xlKuFqCuI?t=290
// To be used in the console of http://linalg.novidee.com or any environment with mathjs
function deriv(fcode, a, step = 0.01) {
return (fcode.eval({ x: a + step }) - fcode.eval({ x: a })) / step;
}
function newton(f, precision, seed = 0) {
const fcode = math.parse(f).compile();
@jdmichaud
jdmichaud / lut.js
Created June 21, 2019 06:47
Modality / VOI Lut
function modalityLutFunctor(s, i) {
return (x) => s * x + i;
}
function voiLutFunctor(wc, ww, maxOutput, minOutput) {
const left = wc - ww / 2;
const right = wc + ww / 2;
const a = (maxOutput - minOutput) / (right - left);
const b = -left * a;
return (x) => a * x + b;
fn main() {
let longest = vec![vec![1], vec![2, 3], vec![4]]
.into_iter()
.fold((vec![], 0), |acc, value| {
let length = value.len();
if length > acc.1 { (value, length) } else { acc }
});
println!("{:?}", longest);
}
@jdmichaud
jdmichaud / prepare_vulkan_ubuntu.sh
Last active August 29, 2019 14:56
Prepare a dev environment on vulkan (WIP)
curl -sOL https://www.x.org/releases/individual/lib/libXext-1.3.4.tar.gz
tar xf libXext-1.3.4.tar.gz
cd libXext-1.3.4
./configure
make -j `nproc`
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:`pwd`
export CPPFLAGS="$CPPFLAGS -I`pwd`/include"
export LDFLAGS="$LDFLAGS -L`pwd`/src/.libs"
cd ..