Skip to content

Instantly share code, notes, and snippets.

View biancadanforth's full-sized avatar

Bianca Danforth biancadanforth

  • Mozilla
  • Pittsburgh, PA
View GitHub Profile
@biancadanforth
biancadanforth / Improve ruleset performance with mostly low hanging fruit.md
Last active March 24, 2020 02:09
Draft issue to file on mozilla-services/fathom-login-forms to improve model performance

Since Bug 1595244 landed yesterday (based on the model at bff6995c), we have started to get some telemetry regarding how long it takes to show the password generation UI. We also did some profiling this afternoon. Taking both of these together, we think it would be prudent to make some relatively straightforward changes to the ruleset to improve its performance.

The following numbers are based on profiling Nightly, taking an average of 5 runs for a locally hosted registration page. Taken together, these sets of changes would speed up the model by about 42%, and there may be more low hanging fruit as well.

The diff below would speed up the model by about 25%. This would not require any retraining.

diff --git a/toolkit/components/passwordmgr/NewPasswordMode
@biancadanforth
biancadanforth / benchmarking.js
Created January 14, 2020 04:45
Benchmarking RegExp vs URL class for domain matching
/**
* Motivation: For a list of domains, is RegExp domain matching or URL class domain matching
* more performant in Firefox's JS engine? I used the website ``jsben.ch`` to measure.
* Spoiler: The URL class approach is 11% faster. Can this approach work with the
* ``matchSubdomains`` option?
*/
// Setup block
const domains = ["nytimes.com", "www.npr.org"];
const url = "https://www.nytimes.com/2020/01/13/us/politics/russian-hackers-burisma-ukraine.html?action=click&module=Top%20Stories&pgtype=Homepage";
@biancadanforth
biancadanforth / are_two_JSON_objects_the_same.py
Last active November 6, 2019 02:43
Check if two JSON objects are the same by first ordering them
import json, os
# Put filenames here; this script assumes these files are in the same dir as the script
FILENAME_1 = "2.json"
FILENAME_2 = "3.json"
def ordered(obj):
if isinstance(obj, dict):
return sorted((k, ordered(v)) for k, v in obj.items())
@biancadanforth
biancadanforth / Bug_1542035_QA_Test_Plan.md
Last active August 27, 2019 06:52
Bug 1542035 QA Test Plan

((Below is the QA Test Plan. I will upload the test extensions before merge day.))

Bug 1542035 QA Test Plan

Setup

  1. Open Firefox Beta 70 in a new profile
  2. Download the following test extensions attached to this bug:
  • Test Extension 1: 1542035-test-extension-1-1.0.zip
    • Extension with Background script and browserAction toolbar button. Clicking the browserAction toolbar button opens a popup with a menu.
  • Test Extension 2: 1542035-test-extension-2-1.0.zip
@biancadanforth
biancadanforth / day03.js
Last active July 23, 2019 15:44
Day 03 Advent of Code implemented in JS and Python with TDD (https://adventofcode.com/2015/day/3)
const fs = require("fs");
function main() {
const path = __dirname + "/input";
let input = fs.readFileSync(path, { encoding: "utf8" });
console.log("Day 3, part 1: ", part1(input)); // 2572
console.log("Day 3, part 2: ", part2(input)); // 2631
}
@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);
@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");
/* 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 / 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());
},
@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: