Skip to content

Instantly share code, notes, and snippets.

@dcantu476
dcantu476 / pizza-shop-1.ts
Last active February 3, 2020 18:51
pizza-shop
build() {
// Add the Toppings!
}
bake() {
// Put it in the oven and let it bake!
}
box() {
// Let it cool and then box it up!
}
@dcantu476
dcantu476 / pizza-shop-2.ts
Last active February 3, 2020 18:56
Pizza Shop
build() {
// Add the Toppings!
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!");
}
bake() {
// Put it in the oven and let it bake!
notifyTheCustomerOfTheStatus("Pizza is done baking!");
}
box() {
// Let it cool and then box it up!
@dcantu476
dcantu476 / pizza-shop-3.ts
Created February 3, 2020 18:59
Pizza Shop
build() {
// Add the Toppings!
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!");
notifyTheEmployeesOfTheStatus("Pizza is ready for the oven!");
}
@dcantu476
dcantu476 / pizza-shop-4.ts
Created February 3, 2020 19:00
Pizza Shop
build() {
// Add the Toppings!
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!");
if (employeeIsClockedIn && employeeIsResponsibleForTask) {
notifyTheEmployeesOfTheStatus("Pizza is ready for the oven!");
}
}
@dcantu476
dcantu476 / pizza-shop-5.ts
Last active February 3, 2020 19:02
Pizza Shop
build() {
// Add the Toppings!
if (userAllowsNotifications) {
notifyTheCustomerOfTheStatus("Pizza is ready for the oven!");
}
if (employeeIsClockedIn && employeeIsResponsibleForTask) {
notifyTheEmployeesOfTheStatus("Pizza is ready for the oven!");
}
}
bake() {
@dcantu476
dcantu476 / pizza-shop-6.ts
Last active February 3, 2020 19:08
Pizza Shop
const pizzaCookingSubject = new Subject();
build() {
// Do any steps to build a pizza
pizzaCookingSubject.next('Build Done');
}
bake() {
// Bake your pizza
pizzaCookingSubject.next('Baking Done');
}
@dcantu476
dcantu476 / pizza-shop-7.ts
Last active February 3, 2020 19:14
Pizza Shop
const pizzaChef = pizzaCookingSubject.subscribe((event: string) => {
// Tell chef a step is complete so he can start the next step.
if (employeeIsClockedIn && employeeIsResponsibleForTask) {
notifyTheEmployeesOfTheStatus(event);
}
})
const pizzaCustomer = pizzaCustomer.subscribe((event: string) => {
// Tell the customer a status update.
if (userAllowsNotifications) {
notifyTheCustomerOfTheStatus(event);
@dcantu476
dcantu476 / calculate_chrome_bookmark_checksum.js
Created May 2, 2021 16:15
Nodejs implementation of creating the chromium bookmark checksum. Fork of python version.
import { createHash } from 'crypto';
// See https://gist.github.com/simon816/afde4d57d5dab8e80120e35596008834
// See https://chromium.googlesource.com/chromium/src/+/master/components/bookmarks/browser/bookmark_codec.cc
const regenChecksum = (roots) => {
const digest = createHash('md5');
const digestUrl = (url) => {
digest.update(url['id'],'ascii');
digest.update(url['name'],'utf16le');