Skip to content

Instantly share code, notes, and snippets.

View mwdchang's full-sized avatar

Daniel Chang mwdchang

View GitHub Profile
@mwdchang
mwdchang / example.json
Created June 18, 2024 19:47
vega multiple time series + transform
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "Multi-series Line Chart",
"data": {
"values": [
{ "variable": "beta", "sample": 0, "time": 1, "value": 1 },
{ "variable": "beta", "sample": 0, "time": 2, "value": 2 },
{ "variable": "beta", "sample": 0, "time": 3, "value": 3 },
{ "variable": "beta", "sample": 0, "time": 4, "value": 3 },
@mwdchang
mwdchang / example.json
Created June 17, 2024 14:38
Vega/vegalite: plot + raincloud
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "data/unemployment-across-industries.json"},
"transform": [{"calculate": "random()", "as": "jitter"}],
"vconcat": [
{
"width": 500,
"height": 100,
"mark": "area",

Find excluding patterns

find . -not ( -name node_modules -prune ) | xargs wc

@mwdchang
mwdchang / index.html
Created December 22, 2022 02:32
Mixing MatterJS with D3JS
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.18.0/matter.min.js" integrity="sha512-5T245ZTH0m0RfONiFm2NF0zcYcmAuNzcGyPSQ18j8Bs5Pbfhp5HP1hosrR8XRt5M3kSRqzjNMYpm2+it/AUX/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.0/d3.min.js" integrity="sha512-jXsLjbg/Pr8F5U2evjFaEci7mImlUix865lbvnNmp5TzS86+VTTFVDz7FFTS6VHdhSn7UJ4tjZdvpp0GgT0fZA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
<svg id="svg" style="width: 100%; height: 100%"></svg>
</body>
<script>
@mwdchang
mwdchang / Dockerfile
Last active August 4, 2022 20:18
Docker file for IJulia + Catlab
# https://github.com/andferrari/julia_notebook
FROM "jupyter/minimal-notebook"
USER root
ENV JULIA_VERSION=1.7.3
RUN mkdir /opt/julia-${JULIA_VERSION} && \
cd /tmp && \
wget -q https://julialang-s3.julialang.org/bin/linux/x64/`echo ${JULIA_VERSION} | cut -d. -f 1,2`/julia-${JULIA_VERSION}-linux-x86_64.tar.gz && \
@mwdchang
mwdchang / packages.md
Created July 6, 2022 03:20
Common python package dependencies

pip install torch torchvision torchaudio

pip install jupyterlab

pip install numpy scipy scikit-learn

pip install tqdm matplotlib pandas

pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.11.0+cpu.html

@mwdchang
mwdchang / matrix-factorization-2.ipynb
Created December 29, 2021 01:36
matrix factorization
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwdchang
mwdchang / index.html
Created December 1, 2021 04:21
jsdelivr module loading example
<html>
<head>
</head>
<body>
</body>
<script type="module">
import { loadImage, hatchFilter } from 'https://cdn.jsdelivr.net/gh/mwdchang/image-util/dist/index.js';
const createCanvas = (img) => {
const canvas = document.createElement('canvas');
@mwdchang
mwdchang / gh-pages.sh
Created April 9, 2021 22:56
gh-pages branch manipulation
#!/usr/bin/env bash
DIR=dist
git checkout --orphan gh-pages
npm run build
git --work-tree $DIR add --all
git --work-tree $DIR commit -m "gh-pages"
git push origin HEAD:gh-pages --force
rm -rf $DIR
git checkout -f master
@mwdchang
mwdchang / heap.js
Created March 4, 2021 04:42
Simple quickie binary heap
class Heap {
constructor(maxsize) {
this.size = 0;
this.maxsize = maxsize;
this.data = [this.maxsize + 1];
}
getParent(index) { return Math.round( index / 2); }
getLeftChild(index) { return 2 * index; }
getRightChild(index) { return 2 * index + 1; }