Skip to content

Instantly share code, notes, and snippets.

View flodolo's full-sized avatar

Francesco Lodolo flodolo

View GitHub Profile
@flodolo
flodolo / cities.txt
Created July 23, 2026 05:33
Test wikidata cities
# City list — one name per line. Blank lines, '#' comments, and
# country-header lines (ending in ':') are ignored.
US:
San Francisco
Seattle
Miami
Washington D.C.
Houston
Dallas
@flodolo
flodolo / translation_time_report.py
Last active July 23, 2026 10:13
Time to translate (Pontoon)
# ============================================================
# Time-to-translate report for Firefox products.
# Run in Django shell: make shell -> ./manage.py shell then paste.
# Prints CSV to stdout (copy-paste into a spreadsheet).
# ============================================================
import csv
import io
import sys
from datetime import datetime, timezone as dt_timezone
@flodolo
flodolo / load_chs_backfill.py
Last active July 3, 2026 06:41
Backfill CHS data
"""
Backfill Community Health Score (CHS) history into Pontoon's
LocaleHealthSnapshot table from the spreadsheet data extracted by
extract_chs_backfill.py.
Scores and the final CHS are RECOMPUTED here from the raw inputs using the live
pontoon.insights.chs.compute_chs, so stored values stay consistent with the
current formula (rather than copying the sheet's precomputed totals). The sheet
total is used only to print a verification diff.
@flodolo
flodolo / extract_chs_backfill.py
Created July 1, 2026 08:43
Pontoon: Scripts to extract CHS data from spreadsheets, and load it to DB
"""
Extract Community Health Score (CHS) data from the historical monthly
spreadsheets so it can be backfilled into Pontoon's LocaleHealthSnapshot table.
Each spreadsheet is named YYYY-MM.xlsx and holds a "Summary" sheet with one
row per locale. The score for a month is recorded on the 1st of the *following*
month (matching how the automated snapshots work), so 2025-01.xlsx maps to a
created_at of 2025-02-01.
This script only reads the raw inputs needed to recompute the score in Django:
#!/usr/bin/env bash
#
# Reproduce bug 2049845 (catastrophic AboutNewTabResourceMapping observer
# re-entrancy -> ballooning memory + main-thread freeze) on a LOCAL build.
#
# The hang needs THREE ingredients together:
# 1. newtab running as the train-hop XPI (not the built-in add-on), so the
# AboutNewTabResourceMapping observer is actually installed.
# 2. Many active langpacks (>=20) so there are enough locales for the
# L10nRegistry/LocaleService source churn to matter.
@flodolo
flodolo / run-langpack-profile.sh
Created June 24, 2026 19:48
Run local build with langpacks
#!/usr/bin/env bash
#
# Run the local Firefox build on a clean profile with:
# - intl.locale.requested set to an empty value (forces OS-locale negotiation)
# - a batch of 152.0.2 release langpacks pre-installed
# - the nimbus-devtools extension installed
#
# The langpacks match the local 152 build version, so they install as-is.
set -euo pipefail
@flodolo
flodolo / mobile_vpn_completion.py
Created June 24, 2026 16:57
VPN mobile completion
#!/usr/bin/env python3
"""Query Transvision for IP-protection strings and report completion per locale,
then map a CSV of country/locale/DAUs to the best-matching Transvision locale."""
import csv
import io
import json
import sys
import urllib.request
import urllib.parse
@flodolo
flodolo / l10n_docs.patch
Created June 8, 2026 06:57
Fix l10n docs
diff --git a/intl/l10n/docs/fluent/review.md b/intl/l10n/docs/fluent/review.md
index febf7af2bc59..5ab292812aca 100644
--- a/intl/l10n/docs/fluent/review.md
+++ b/intl/l10n/docs/fluent/review.md
@@ -14,7 +14,7 @@ This document is intended as a guideline for developers and reviewers when
working with FTL (Fluent) files. As such, it’s not meant to replace the
[existing extensive documentation](./tutorial.html) about Fluent.
-[Herald] is used to set the group [fluent-reviewers] as blocking reviewer for
+[Herald](https://phabricator.services.mozilla.com/herald/) is used to set the group [fluent-reviewers](https://phabricator.services.mozilla.com/tag/fluent-reviewers/) as blocking reviewer for
from copy import deepcopy
from moz.l10n.migrate import Migrate
from moz.l10n.migrate.utils import get_entry
from moz.l10n.model import Expression, PatternMessage, VariableRef
def copy_int_to_float(src_id):
"""Like moz.l10n.migrate.copy() with replace=, but deep-copies the entry
first so the source resource is not mutated. Rewrites any `integer`
@flodolo
flodolo / time_to_translation.py
Created April 21, 2026 10:59
Time to translation
from pontoon.base.models import Project, Locale, Entity, Translation
from django.db.models import F
from datetime import datetime, timezone
project_slug = "firefox"
# Top 15 desktop locales based on DAU, excluding en-*
locale_codes = ["de", "fr", "es-ES", "ru", "pl", "pt-BR", "it", "zh-CN", "ja", "es-MX", "nl", "id", "cs", "hu", "es-AR"]
start_date = datetime(2026, 1, 1, tzinfo=timezone.utc)
end_date = datetime(2027, 1, 1, tzinfo=timezone.utc)