Skip to content

Instantly share code, notes, and snippets.

View biancadanforth's full-sized avatar

Bianca Danforth biancadanforth

View GitHub Profile
@biancadanforth
biancadanforth / Algorithms_Coursera_Part IV_Programming_Assignment_2.js
Last active April 14, 2019 23:55
Algorithms_Coursera_Part IV_Programming_Assignment_2.js
/* eslint-env node */
/**
* -------------------------- Part 1 -----------------------------
*/
/**
* In this assignment you will implement one or more algorithms for the traveling
* salesman problem, such as the dynamic programming algorithm covered in the
* video lectures. Here is a data file describing a TSP instance.
@biancadanforth
biancadanforth / Graph.js
Last active April 20, 2019 20:57
Algorithms_Coursera_Part IV_Programming_Assignment_3.js
/* eslint-disable arrow-body-style, object-property-newline, no-undef */
class Graph {
/*
* Construct a graph
*
* @param {Map} nodeVsLocation - node => {x: number, y: number}
*/
constructor(nodeVsLocation) {
this.nodeVsLocation = nodeVsLocation;
@biancadanforth
biancadanforth / 1Algorithms_Coursera_Part_IV_Programming_Assignment_4.js
Last active May 1, 2019 17:53
Stanford Algorithms Coursera Part 4 Programming Assignment 4
We couldn’t find that file to show.
@biancadanforth
biancadanforth / test_local_storage_live_reload.shell
Created May 8, 2019 21:48
Bug_1542035_xpcshell_task_test_local_storage_live_reload_failing
bdanforth ~/src/mozilla-unified $ ./mach test devtools/server/tests/unit/test_extension_storage_actor.js
0:01.27 INFO Found node at /Users/bdanforth/.mozbuild/node/bin/node
0:01.27 INFO Found moz-http2 at /Users/bdanforth/src/mozilla-unified/testing/xpcshell/moz-http2/moz-http2.js
0:01.39 INFO Running tests sequentially.
0:01.39 SUITE_START: xpcshell - running 1 tests
0:01.41 INFO profile dir is /var/folders/r4/54vpbnzx4_l3jk8cmjgs5v040000gn/T/firefox/xpcshellprofile
0:01.42 TEST_START: devtools/server/tests/unit/test_extension_storage_actor.js
0:01.42 INFO devtools/server/tests/unit/test_extension_storage_actor.js | full command: ['/Users/bdanforth/src/mozilla-unified/objdir-frontend-debug-artifact/dist/Nightly.app/Contents/MacOS/xpcshell', '-g', '/Users/bdanforth/src/mozilla-unified/objdir-frontend-debug-artifact/dist/Nightly.app/Contents/Resources', '-a', '/Users/bdanforth/src/mozilla-unified/objdir-frontend-debug-artifact/dist/Nightly.app/Contents/Resources/browser', '-r', '/Users/bdanforth/src/moz
bdanforth ~/src/mozilla-unified $ ./mach test devtools/server/tests/unit/test_extension_storage_actor.js
0:01.30 INFO Found node at /Users/bdanforth/.mozbuild/node/bin/node
0:01.30 INFO Found moz-http2 at /Users/bdanforth/src/mozilla-unified/testing/xpcshell/moz-http2/moz-http2.js
0:01.41 INFO Running tests sequentially.
0:01.41 SUITE_START: xpcshell - running 1 tests
0:01.43 INFO profile dir is /var/folders/r4/54vpbnzx4_l3jk8cmjgs5v040000gn/T/firefox/xpcshellprofile
0:01.43 TEST_START: devtools/server/tests/unit/test_extension_storage_actor.js
0:01.43 INFO devtools/server/tests/unit/test_extension_storage_actor.js | full command: ['/Users/bdanforth/src/mozilla-unified/objdir-frontend-debug-artifact/dist/Nightly.app/Contents/MacOS/xpcshell', '-g', '/Users/bdanforth/src/mozilla-unified/objdir-frontend-debug-artifact/dist/Nightly.app/Contents/Resources', '-a', '/Users/bdanforth/src/mozilla-unified/objdir-frontend-debug-artifact/dist/Nightly.app/Contents/Resources/browser', '-r', '/Users/bdanforth/src/moz
@biancadanforth
biancadanforth / 0README.md
Last active May 31, 2019 17:25
Test Cases for Staff Engineer, Data Products On-Site Pair Programming Exercise (https://github.com/biancadanforth/staff-engineer-data-products)

Pair Programming Exercise

Problem Statement

In this exercise, we will port a JavaScript implementation of the Floyd-Warshall algorithm to Python.

This algorithm computes the shortest path between any node and any other node in a directed graph with integral edge lengths.

We are given:

@biancadanforth
biancadanforth / HostVsStoresRouter.js
Last active June 8, 2019 06:49
HostVsStoresRouter class Bug 1542035
// in storage actor's `populateStoresForHost` method...
this.hostVsStores = new HostVsStoresRouter(host);
// Add an intermediary "area" layer between host and storeMap in this.hostVsStores
class HostVsStoresRouter {
constructor(host) {
this.DEFAULT_AREA = "local";
// a triple nested map: host => areaMap, where areaMap is area => storeMap and storeMap is key => value
this.router = (new Map()),set(host, new Map());
},
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {Cc, Ci, Cu, CC} = require("chrome");
const protocol = require("devtools/shared/protocol");
const {LongStringActor} = require("devtools/server/actors/string");
const {DebuggerServer} = require("devtools/server/main");
@biancadanforth
biancadanforth / test_extension_storage_actor.js
Last active June 12, 2019 17:42
temporary backup for bug 1542035 adding rest of test coverage for issue #4
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* globals browser */
"use strict";
const {
AddonTestUtils,
} = ChromeUtils.import("resource://testing-common/AddonTestUtils.jsm");
@biancadanforth
biancadanforth / isVisible.js
Last active July 16, 2019 02:48
Performant and comprehensive rewrite (Rev 1 is BEFORE, Rev 2+ is AFTER) of `isVisible` in Price Tracker (https://github.com/mozilla/price-tracker/)
// Avoid reading `display: none` due to Bug 1381071
isVisible(fnode) {
const element = fnode.element;
if (element.getBoxQuads().length === 0) {
// The element has no box (display: none subtree?), checking
// getBoundingClientRect instead for a width and height of 0 only tells
// us it is a zero-sized box.
return false;
}
const eleStyle = getComputedStyle(element);