Skip to content

Instantly share code, notes, and snippets.

View flodolo's full-sized avatar

Francesco Lodolo flodolo

View GitHub Profile
@flodolo
flodolo / benchmark_translation_save_console.py
Last active March 23, 2026 07:52
Benchmark save translations
import time
from django.conf import settings
from django.db import connection, transaction
from django.db.models import F
from pontoon.base.models import Resource, Translation, TranslatedResource
settings.DEBUG = True
@flodolo
flodolo / benchmark_stats.py
Last active March 21, 2026 08:10
Test to benchmark different approach to stats
"""
Benchmark: current calculate_stats() (5 queries) vs single aggregate approach.
Runs against the top 10 largest resources for the Italian (it) locale.
Safe for production: read-only queries, low iteration count.
"""
import timeit
from functools import partial
from django.db.models import Count, Q
from pontoon.base.models import Locale, TranslatedResource, Translation
@flodolo
flodolo / github_access_report.py
Created March 18, 2026 07:05
Check access to repositories within GitHub organization
#!/usr/bin/env python3
"""
GitHub Org Repository Access Report
Checks your access level to all public, active repositories in a GitHub
organization and prints a grouped report, distinguishing direct vs.
team-inherited permissions.
Usage:
python github_access_report.py --org <org> --token <token>
@flodolo
flodolo / fix_doh_labels.py
Created March 11, 2026 05:22
Fix DOH labels in fx150
#!/usr/bin/env python3
"""
Remove trailing punctuation from specific Fluent message attributes in
browser/browser/preferences/preferences.ftl across all locales.
- preferences-doh-radio-default/custom/off: fix .description
- preferences-doh-fallback-label: fix .label
"""
import os
@flodolo
flodolo / time_to_translation.py
Last active March 10, 2026 07:38
Pontoon: time to translate/review
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(2026, 12, 31, 23, 59, 59, tzinfo=timezone.utc)
@flodolo
flodolo / completion.py
Created February 11, 2026 13:23
Firefox Onboarding Refresh completion status (v148)
#!/usr/bin/env python3
"""
Pontoon translation coverage report for a given search query.
- Queries Pontoon search/translations endpoint (custom User-Agent).
- Extracts entity IDs.
- Fetches translations for each entity.
- Computes per-locale completion across the entity set.
Requires: requests
@flodolo
flodolo / gist:7eaa9369dca047398ebf28a95af088f8
Created January 27, 2026 07:41
Git diff for bug 2010181
diff --git a/browser/components/preferences/moreFromMozilla.js b/browser/components/preferences/moreFromMozilla.js
index 109d334ea334..d426bebcc1bf 100644
--- a/browser/components/preferences/moreFromMozilla.js
+++ b/browser/components/preferences/moreFromMozilla.js
@@ -170,7 +170,7 @@ var gMoreFromMozillaPane = {
products.push({
id: "mdn",
- title_string_id: "more-from-moz-mdn-title",
+ title_string_id: "more-from-moz-mdn-title2",
@flodolo
flodolo / test.ftl
Created November 12, 2025 06:07
Test FTL file with variants
-brand-account =
{ $capitalization ->
[uppercase] Mozilla Account
*[lowercase] Mozilla account
}
test-message-lowercase = Your { -brand-account }
test-message-uppercase = Your { -brand-account(capitalization: "uppercase") }
@flodolo
flodolo / remove_obsolete_files.py
Created October 16, 2025 05:50
Remove thunderbird-l10n obsolete files
#!/usr/bin/env python3
import os
def extractFileList(repository_path):
"""
Extract the list of supported files. Store the relative path and ignore
specific paths.
"""
@flodolo
flodolo / strings.xml
Created September 25, 2025 14:34
Test android parsing
<!DOCTYPE resources>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="single_quote">They\'re great</string>
<string name="double_quotes">They are \"great\"</string>
<string name="both_quotes">They\'re really \"great\"</string>
</resources>