Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / mdtest.js
Created April 19, 2018 13:24
A tiny markdown web renderer
// npm install express highlight.js marked morgan mustache
const fs = require('fs');
const express = require('express');
const morgan = require('morgan');
const marked = require('marked');
const highlight = require('highlight.js');
const Mustache = require('mustache');
const config = {
<!DOCTYPE html>
<html>
<head>
<title>Least Squares</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/4.4.2/math.js"></script>
<script src="main.js"></script>
<style>
.graph {
border: solid 1px black;
display: block;
@jdmichaud
jdmichaud / sample.gpi
Last active May 23, 2018 20:22
Plotting a function with gnuplot (with imgcat)
gnuplot -e "set term png; f(x)=1+4*x-x**2; plot f(x)" | imgcat
gnuplot -e "set term png; set output 'plot.png'; f(x)=1+4*x-x**2; plot f(x)"
@jdmichaud
jdmichaud / Xcalculus.md
Last active March 5, 2020 18:15
Linear Algebra (and some calculus (and some geometric algebra))

Better version

Source

Euler's and complex numbers

The purpose of this article is to be an informal reminder on how do we get from $1+1=2$ to $i^i=e^{-\frac{\pi}{2}}$.

Trigonometric identities

@jdmichaud
jdmichaud / index.html
Last active May 24, 2018 15:22
CodeMirror integration
<!DOCTYPE html>
<html>
<head>
<title>Code Mirror Tests</title>
<link rel="stylesheet" href="dist/bundle.css">
<script src="dist/main.js"></script>
<script>
window.onload = () => {
createEditor(document.getElementById('editor'));
}
@jdmichaud
jdmichaud / README.md
Last active August 21, 2018 16:56
Minimalistic WebAssembly example

Tools

Install the emscripten toolchain. See instructions here

How does this works?

We will compile a simple c program using emscripten which will generate WebAssembly code. Then, in a simple web page, we will load the resulting wasm generated file and pass it to the WebAssembly facility now found in any decent browser. Simple as that!

@jdmichaud
jdmichaud / ks.py
Created July 22, 2018 09:21
Knapsack
import sys
# How to run:
# cat << EOF | python ks.py
# 1
# 10
# 2 6 7 1 5
# 1 1 1 1 1
# EOF
# [(2, 1), (1, 1), (5, 1)]
@jdmichaud
jdmichaud / index.html
Last active November 3, 2021 15:34
Canvas interpolation investigation
<!DOCTYPE html>
<html>
<head>
<meta charset=UTF-8>
<title>Canvas interpolation test</title>
<script>
function main() {
const canvas = document.getElementById('canvas');
canvas.width = 2;
canvas.height = 2;
@jdmichaud
jdmichaud / test.py
Created July 24, 2018 20:04
Subsample artefact
import math
import numpy
import imageio
from matplotlib import pyplot
def resize(img, size):
(width, height) = size
resized = []
wratio = len(img[0]) / width
@jdmichaud
jdmichaud / whole.c
Last active August 1, 2018 14:09
Load a whole file in C with mmap
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char **argv) {