Skip to content

Instantly share code, notes, and snippets.

View jdmichaud's full-sized avatar

jdmichaud

View GitHub Profile
@jdmichaud
jdmichaud / test-capacity.sh
Created August 11, 2018 21:19
Test USB drive capacity
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "To test for 16G capacity"
echo "usage: testcap.sh 16"
exit 1
fi
echo "checking for capacity ${1}G"
@jdmichaud
jdmichaud / Dockerfile
Created September 4, 2018 18:53
Dockerfile for sc-im build
FROM ubuntu:bionic
RUN apt update
RUN apt install -y \
bison \
libncurses5-dev \
libncursesw5-dev \
libxml2-dev \
libzip-dev \
git
@jdmichaud
jdmichaud / pygame.py
Last active September 6, 2018 16:53
Simple pygame example
import sys
import pygame
# Something that look like object literal
class Object:
def __init__(self, **kwds):
self.__dict__.update(kwds)
g_event_map = {}
@jdmichaud
jdmichaud / object.py
Created September 8, 2018 15:04
Python object literal
# Something that look like a javascript object literal
class Object:
def __init__(self, **kwds):
self.__dict__.update(kwds)
def __str__(self):
return str(self.__dict__)
test = Object(
key=value
@jdmichaud
jdmichaud / main.js
Last active September 10, 2018 12:40
Test zip methods
async function inflatePNG(buffer, mark) {
const canvas = document.createElement('canvas');
canvas.width = 512;
canvas.height = 512;
const context = canvas.getContext('2d');
const result = new Uint8Array(512 * 512);
performance.mark(`${mark}-start`);
const url = window.URL.createObjectURL(new Blob([buffer], { type: 'image/png' }));
const image = await new Promise(resolve => {
const i = new Image();
@jdmichaud
jdmichaud / tensorflow.cross.shim.js
Created October 2, 2018 16:49
Tensorflow tensor cross product shim
function cross(rhs) {
const lhs = this;
if (lhs.shape[1] !== 1 || rhs.shape[1] !== 1 || lhs.shape[0] !== 3 || rhs.shape[0] !== 3) {
throw new Error(`cross product only implemented for vector of shape (3, 1)`);
}
// Cross product
const u = lhs.dataSync();
const v = rhs.dataSync();
return tf.tensor([
[u[1] * v[2] - u[2] * v[1]],
@jdmichaud
jdmichaud / loadScript.js
Last active October 3, 2018 17:48
Mass matrix multiplication in tensorflow
function _loadScript(path) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = path;
document.head.appendChild(script);
}
@jdmichaud
jdmichaud / circularDependencyDetector.js
Created October 10, 2018 07:27
Detect circular dependency in object
const circularDepDetector = (function () {
const set = new Set();
return function(key, value) {
if (set.has(value)) {
return 'CIRCULAR DEPENDENCY';
}
set.add(value);
return value;
};
})();
@jdmichaud
jdmichaud / raytracer.rs
Last active October 22, 2018 10:23 — forked from joshmarinacci/main.rs
Simple ray tracer in Rust
#[derive(Copy,Clone,Debug)]
struct Vector {
x: f32,
y: f32,
z: f32
}
impl Vector {
fn new(x: f32,y: f32,z: f32) -> Vector {
Vector { x:x, y:y, z:z }
@jdmichaud
jdmichaud / cube.html
Last active October 26, 2018 15:25
CSS 3d rotation of a cube
<!DOCTYPE html>
<html>
<title>Cube</title>
<!-- Trackball is used to test the rotation with the mouse, but you can rotate -->
<!-- the cube from the command line this way: -->
<!-- > rotateCube('cube1', [1, -1, 0], -Math.PI / 5); -->
<script src="trackball.js"></script>
<style>
* { box-sizing: border-box; }