Skip to content

Instantly share code, notes, and snippets.

View mwdchang's full-sized avatar

Daniel Chang mwdchang

View GitHub Profile
@mwdchang
mwdchang / css-book.html
Created August 15, 2024 12:29
CSS flip-through book
<html>
<head><title> Book:: Demos </title>
<style>
#canvas {
-webkit-perspective: 800px;
-webkit-perspective-origin: 50% 200px;
-webkit-transform: rotateY(0deg) rotateX(0deg);
-webkit-transform-style: preserve-3d;
}
@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; }