Skip to content

Instantly share code, notes, and snippets.

// Javascript console script for exporting all images from https://canvas.apps.chrome/ on 2023-01-01
const sleep = ms => new Promise(r => setTimeout(r, ms)); // https://stackoverflow.com/a/39914235
const gi = document
.getElementById("drawing-app")
.shadowRoot
.getElementById("drawing-gallery")
.shadowRoot
.getElementById("main")
@rcyeh
rcyeh / calendar_events.sh
Created September 6, 2020 17:19
Convert NYC 2020-2021 School Year Calendar to csv for import to Google Calendar
curl https://www.schools.nyc.gov/about-us/news/2020-2021-school-year-calendar > raw.html
cat raw.html | sed -z -e " \
s/[\r\n]//g;
s/.*<table>//;
s/<\/table>.*//;
s/ </</g;
s/<\/*strong>//g;
s/<\/tr>\(<\(\/thead\|\/tbody\|tbody\|tr\)>\)*/\n/g;
s/<\/t[hd]><t[hd]>/\t/g;
@rcyeh
rcyeh / np-completeness-reduce-3sat-to-3dm.md
Last active June 15, 2023 22:24
Reducing 3-SAT to 3-dimensional matching

Watched Eric Demaine's lecture and initially did not understand the reduction from 3-SAT to 3-dimensional matching.

  1. Complexity: P, NP, NP-completeness, Reductions https://youtu.be/eHZifpgyH_4?t=2786

Goal

To reduce 3-SAT to 3DM, we need to show how to express every 3-SAT problem as a 3DM problem. If 3DM has a solution, then that solution can be applied to solve any 3-SAT problem.

@rcyeh
rcyeh / water_jug.py
Created January 5, 2017 02:05
Water Jug Solver
"""
https://www.eecis.udel.edu/~mccoy/courses/cisc4-681.10f/lec-materials/handouts/search-water-jug-handout.pdf
Consider the following problem:
A Water Jug Problem:
You are given two jugs, a 4-gallon one and a 3-gallon
one, a pump which has unlimited water which you can use
to fill the jug, and the ground on which water may be
poured. Neither jug has any measuring markings on it.
@rcyeh
rcyeh / Egg.md
Last active August 29, 2015 14:18
Foods containing common allergens

Foods containing egg

  • Pastry
    • Egg breads: Brioche, challah
    • Baked goods with a shiny golden surface produced with an egg wash, such as croissants (unless done with apricot jam)
    • Empanada, pattie
    • Popover
    • some breads
    • most doughnuts
  • almost no bagels, except egg bagels