Skip to content

Instantly share code, notes, and snippets.

View biancadanforth's full-sized avatar

Bianca Danforth biancadanforth

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / .hgrc.diff
Created March 24, 2020 19:54
Diff between my current ~/.hgrc and Mythmon's for `alias`, `revsetalias` and `templates`
diff --git a/Users/bdanforth/.hgrc b/Users/bdanforth/.hgrc-mythmon
index d2d9e52..e32a8cb 100644
--- a/Users/bdanforth/.hgrc
+++ b/Users/bdanforth/.hgrc-mythmon
@@ -26,13 +26,11 @@ absorb =
js-format = /Users/bdanforth/.mozbuild/version-control-tools/hgext/js-format
shelve =
[alias]
-wip = log --graph --rev=wip --template=wip
-smart-annotate = annotate -w --skip ignored_changesets
@biancadanforth
biancadanforth / ADDITIONAL_RESOURCES.MD
Last active May 11, 2020 00:07
Front End Performance and Profiling Team Session additional resources

What happens after Outreachy?

Disclaimer: These thoughts are my own (Bianca Danforth) based on my experience starting as an Outreachy at Mozilla and now working as a Senior Software Engineer.

Congratulations! You’ve just completed your Outreachy internship. You may be wondering: Where do I go from here? How do I get a job in software engineering? Below are a set of steps I recommend based on my own experience.

Introspect

  • Identify goals
    • What are your professional goals?
    • If you're not sure where to start, ask other people you admire what their professional goals are.
  • Identify skills
  • What skills do you need to achieve your goals (those you already have, those that you need to improve, and those you need to learn)?
@biancadanforth
biancadanforth / call-paypal-api-requiring-bearer-token.js
Last active December 23, 2020 23:08
Fetching an ephemeral OAuth2 bearer token from PayPal sandbox when we don't have one or it's expired and then calling a PayPal API that requires the token.
const fetch = require("node-fetch");
const { getPayPalBearerToken } = require("../../github/bin/get-oauth2-token/bin/getOAuth2Token");
const PAYPAL_SANDBOX_BASE_URL = "https://api-m.sandbox.paypal.com";
async function postToPayPalAPI(apiPath, body) {
const bearerToken = await getPayPalBearerToken();
const metadata = {
body,
headers: {
const fetch = require("node-fetch");
const config = {
paypal: require("./paypal-config")["DEV"],
};
const PAYPAL_SANDBOX_NVP_BASE_URL = "https://api-3t.sandbox.paypal.com/nvp";
const nvpUrl = new URL(PAYPAL_SANDBOX_NVP_BASE_URL);
const params = {
USER: config.paypal.USER, // Merchant username
PWD: config.paypal.PWD, // Merchant password