Skip to content

Instantly share code, notes, and snippets.

View alvinwan's full-sized avatar
🦉
🧀🍰

Alvin Wan alvinwan

🦉
🧀🍰
View GitHub Profile
@alvinwan
alvinwan / questions.py
Created September 1, 2016 06:07
resolve imports and remove solutions to generate questions .tex
"""Generate LaTeX that only includes solutions for a particular TeX document.
Usage:
questions.py [--source=<src>] [--dest=<dest>]
"""
from TexSoup import TexSoup
from docopt import docopt
SOlUTION_COMMAND = 'sol'
@alvinwan
alvinwan / demo.py
Created April 8, 2017 07:16
Splitting PDFs programmatically using a list of set ranges
"""Demonstration of provided split utility.
Divides a PDF into several chunks and eliminates certain pages from each pdf.
"""
from splits import splits
INPUT_FILE = "./merged.pdf"
OUTPUT_DIRECTORY = "./out"
PAGE_SPLITS = "1-10,11-20,21-30,31-42,43-52,53-64,65-74,75-86,87-98,99-110,111-122,123-134,135-146,147-158,159-168,169-180,181-192,193-204,205-216,217-228,229-240,241-250,251-262,263-274,275-284,285-296,297-308,309-320,321-332,333-344,345-356,357-368,369-380,381-392,393-404,405-416"
@alvinwan
alvinwan / requirements.txt
Last active December 7, 2022 07:28
Converts mesh into a point cloud - accepts .pkl,.off,.xaml,.obj etc.
docopt==0.6.2
trimesh==2.10.18
@alvinwan
alvinwan / autograder.py
Last active May 27, 2017 02:04
Gradescope Autograding for CS189
"""
Check differences between files containing integers.
This script checks the diff between two files and writes to a JSON compatible
with Gradescope's autograder.
Usage:
autograder.py <ref> <subm> [options]
Options:
@alvinwan
alvinwan / errors.py
Created December 4, 2017 11:59
Plotting errors for ridge regression v. ordinary least squares as magnitude in noise increases
import numpy as np
import matplotlib
matplotlib.use('Agg') # wizardry to prevent Tkinter error
import matplotlib.pyplot as plt
n = 100
line = lambda x: 2*x + 3 # true line
e = 10
reg = 1e2
@alvinwan
alvinwan / noob-3d-css-rotate.css
Last active February 21, 2019 18:06
The noob's guide to 3D Transforms with CSS - Rotations
.rotated-square {
transform:
rotateX(20deg) /* flip "up" */
rotateY(-20deg) /* flip "right" */
rotateZ(20deg); /* rotate counter-clockwise */
}
.rotated-square-shorthand {
transform: rotate3d(20deg, -20deg, 20deg);
}
@alvinwan
alvinwan / frame-of-reference.html
Last active February 21, 2019 18:08
The noob's guide to 3D Transforms with CSS - Frame of Reference HTML
<div class="square parent">
<div class="square child"></div>
</div>
@alvinwan
alvinwan / perspective-function.css
Last active February 21, 2019 18:10
The noob's guide to 3D Transforms with CSS - Perspective Function
.square {
transform: perspective(200px) rotateX(20deg);
}
@alvinwan
alvinwan / flipping-card.html
Last active February 21, 2019 18:14
The noob's guide to 3D Transforms with CSS - Flipping Card Example
<div class="scene">
<div class="card">
<div class="face front">front</div>
<div class="face back">back</div>
</div>
</div>
@alvinwan
alvinwan / cube.html
Last active February 21, 2019 18:20
The noob's guide to 3D Transforms with CSS - Cube Example
<div class="scene">
<div class="cube">
<div class="face front">front</div>
<div class="face right">right</div>
<div class="face left">left</div>
<div class="face back">back</div>
<div class="face top">top</div>
<div class="face bottom">bottom</div>
</div>
</div>