Skip to content

Instantly share code, notes, and snippets.

View flodolo's full-sized avatar

Francesco Lodolo flodolo

View GitHub Profile
@flodolo
flodolo / enable_gh_workflows.py
Created March 26, 2025 15:30
Re-enable disabled GitHub workflows in an org
#! /usr/bin/env python
# Requires PyGithub
from github import Github
import configparser
import os
import requests
import sys
@flodolo
flodolo / find_unreferenced_strings.py
Last active March 23, 2025 07:05
Find unrreferenced Fluent strings in mozilla-central
#!/usr/bin/env python3
import json
import os
import signal
import subprocess
import sys
# Capture CTRL+C
unreferenced_entities = []
processed_files = []
@flodolo
flodolo / check_unused.sh
Created March 12, 2025 11:30
Firefox iOS unused strings
#! /usr/bin/env bash
# Extract strings
fx_repo="/Users/flodolo/github/firefox-ios"
python ./extract_ids_strings.py "${fx_repo}/firefox-ios/Shared/Strings.swift"
input="./string_ids.txt"
while IFS= read -r id
do
grep -qr "${fx_repo}/firefox-ios" --include=\*.swift --exclude=Strings.swift -e "\.${id}" && : || echo "${id}"
@flodolo
flodolo / extract_headers.py
Last active March 7, 2025 18:52
fomo-content hack
#!/usr/bin/env python3
import json
import os
import re
import sys
import argparse
def parse_po_file(filepath):
"""
Reads a .po file and returns the value of the header
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from fluent.migrate.helpers import transforms_from
from fluent.migrate.transforms import TransformPattern
import fluent.syntax.ast as FTL
class REPLACE_TOTAL(TransformPattern):
def visit_TextElement(self, node):
@flodolo
flodolo / extract_hg_changesets.py
Last active January 27, 2025 12:45
Script to extract l10n builds changeset for Firefox 68–127
import json
import requests
base_url = "https://product-details.mozilla.org/1.0/l10n/"
changesets = {}
for version in range(68, 128):
version_str = f"{version}.0"
for build_number in range(1, 6):
@flodolo
flodolo / minimize_fontawesome.py
Created January 5, 2025 06:54
Pontoon: minimize Font Awesome
#! /usr/bin/env python
"""
The script looks for TTF fonts in FontAwesome folder. It doesn't use WOFF2
directly, because glyph names seem to be unreliable.
Optimized fonts are saved in `/pontoon/base/static/fonts/` as WOFF2.
The list of possible icons is done searching for `fa-*` in specific files (HTML,
@flodolo
flodolo / analyze.py
Created January 2, 2025 06:43
Pontoon: analyze search options in Heroku logs
#! /usr/bin/env python
import glob
import json
# Find all .json files in logs/
json_files = glob.glob("logs/*.json")
json_files.sort()
@flodolo
flodolo / extract.py
Created November 8, 2024 06:39
Extract spotlight completion
import json
from urllib.request import urlopen
string_ids = [
"browser/browser/newtab/asrouter.ftl:device-migration-fxa-spotlight-sync-body",
"browser/browser/newtab/asrouter.ftl:device-migration-fxa-spotlight-sync-header",
"browser/browser/newtab/asrouter.ftl:device-migration-fxa-spotlight-sync-primary-button",
]
locales = {}
@flodolo
flodolo / amo_localization_data.py
Last active September 16, 2024 18:21
AMO locales data
#!/usr/bin/env python3
import json
import re
import sys
from urllib.parse import quote as urlquote
from urllib.request import urlopen
def main():