Skip to content

Instantly share code, notes, and snippets.

View jackd's full-sized avatar

Dominic Jack jackd

View GitHub Profile
@jackd
jackd / main.dart
Last active March 4, 2026 23:04
Generic type inference bug report: extra type parameter in tensor class, compile time error
enum DType<T extends num> { int64<int>(), float64<double>() }
class Tensor<DT extends DType<T>, T extends num, S> {
final List<T> values;
final DT dtype;
final S shape;
const Tensor(this.values, this.dtype, this.shape);
Tensor<DT2, T2, S> castSwitchedFunc<DT2 extends DType<T2>, T2 extends num>(
@jackd
jackd / main.dart
Created March 4, 2026 22:53
Generic type inference bug report: cast type parameters reversed, type inference fails
enum DType<T extends num> { int64<int>(), float64<double>() }
class Tensor<DT extends DType<T>, T extends num> {
final List<T> values;
final DT dtype;
final Object shape;
const Tensor(this.values, this.dtype, this.shape);
Tensor<DT2, T2> castSwitchedFunc<T2 extends num, DT2 extends DType<T2>>(
@jackd
jackd / main.dart
Created March 4, 2026 22:49
Generic type inference bug report: working example
enum DType<T extends num> { int64<int>(), float64<double>() }
class Tensor<DT extends DType<T>, T extends num> {
final List<T> values;
final DT dtype;
final Object shape;
const Tensor(this.values, this.dtype, this.shape);
Tensor<DT2, T2> castSwitchedFunc<DT2 extends DType<T2>, T2 extends num>(
@jackd
jackd / README.md
Last active September 4, 2024 11:04
Demo of go_router interface inconsistency between GoRoute build and errorBuilder environments

This gist demonstrates a difference in behaviour of GoRouteState.of when instantiated in a child constructed via a GoRoute builder method compared to errorBuilder, despite both GoRouteStates having meaning / being in the function arguments.

Check it out here.

@jackd
jackd / sir.py
Created August 25, 2021 09:25
A super-simple Susceptible-Infection-Recovered (SIR) model with vaccination
"""Basic Susceptible-Infectious-Recovered model."""
import numpy as np
import matplotlib.pyplot as plt
def run(
infectious: int,
r0=1.07, # base daily growth rate
vax_rate=0,
init_vax_prop=0,
@jackd
jackd / README.md
Last active January 24, 2021 14:43
Generalized eigenvalue jvp implementation in jax

After installing jax, run with:

git clone https://gist.github.com/jackd/99e012090a56637b8dd8bb037374900e
cd 99e012090a56637b8dd8bb037374900e
python dirty_test.py
@jackd
jackd / diff.html
Created November 17, 2020 07:43
testing embedly
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Diff to HTML by rtfpessoa</title>
<!--
Diff to HTML (template.html)
Author: rtfpessoa
-->
@jackd
jackd / README.md
Last active September 22, 2020 08:39
SparseTensor vs CSRSparseMatrix matmul benchmark

Sparse Mamul Benchmarks

Script for benchmarking matmuls with SparseTensor vs CSRSparseMatrix.

Installation

pip install tensorflow==2.3
pip install absl-py
git clone https://gist.github.com/jackd/93cf681c67e48c1a25de01bf860c6ab2
@jackd
jackd / README.md
Last active August 2, 2022 12:41
tensorflow graphics keras port for PR #155

Get my forked tensorflow graphics repo and switch to appropriate branch

git clone https://github.com/jackd/graphics.git
cd graphics
git checkout sparse-feastnet
pip install -e .
cd ..

Get this gist:

@jackd
jackd / main.py
Created June 23, 2019 03:59
trimesh_obj_example
import trimesh
import numpy as np
def fix_visual(visual):
from PIL import Image
if isinstance(visual, trimesh.visual.ColorVisuals):
return
material = visual.material
assert(hasattr(material, 'image'))