Skip to content

Instantly share code, notes, and snippets.

View flodolo's full-sized avatar

Francesco Lodolo flodolo

View GitHub Profile
@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():
@flodolo
flodolo / test.py
Created September 12, 2024 11:16
Test python-levenshtein vs RapidFuzz
import Levenshtein
from rapidfuzz.distance import Indel
sentence_pairs = (
("The sky is blue.", "It looks like rain."),
("I love reading books.", "My favorite genre is fantasy."),
("She enjoys playing piano.", "He prefers the guitar."),
("Coffee wakes me up.", "Tea relaxes me."),
("We are going to the park.", "They are staying home."),
("The dog barked loudly.", "The cat quietly meowed."),
@flodolo
flodolo / check_heroku.py
Created August 28, 2024 13:28
Check Heroku log for IPs
import re
import sys
if len(sys.argv) == 1:
sys.exit("Provide the log file as an argument")
ips = {}
filter = re.compile(r"fwd=\"([\d.]+)\"")
threshold = 10
# Copy from Heroku settings
@flodolo
flodolo / check_survey.py
Last active February 15, 2024 06:30
Check survey files exported from Smartling
from glob import glob
import csv
import os
import re
import sys
# Pass a path as an argument, the script will go through all .csv files included.
if len(sys.argv) < 2:
sys.exit("Missing path argument")
path = os.path.abspath(sys.argv[1])
@flodolo
flodolo / phabricator_query.py
Last active January 24, 2024 20:18
Query reviews on phabricator
#!/usr/bin/env python3
import argparse
import datetime
import json
import urllib.parse as url_parse
import urllib.request as url_request
from collections import defaultdict
api_token = "TOKEN"
@flodolo
flodolo / convert.sh
Last active January 28, 2024 08:13
Convert l10n repos to monorepo
#! /usr/bin/env bash
# This script requires git-cinnabar and jq installed
# https://github.com/glandium/git-cinnabar
# https://jqlang.github.io/jq/download/
#
# If you pass a path to the script, it will search for locale clones in that folder.
# If that's not available, it will clone the remote repository for the locale.
clones_path=$1
@flodolo
flodolo / verify_windowsbg_experiment.py
Last active May 22, 2023 13:48
Verify Windows Background Notifications experiment
import json
import sys
from urllib.request import urlopen
# Get translations
translations_url = "https://raw.githubusercontent.com/mozilla-l10n/nimbus-l10n/main/.github/storage/windows_bg_notifications_2023.json"
try:
r = urlopen(translations_url)
translations = json.load(r)["translations"]
except Exception as e:
@flodolo
flodolo / podcasts.md
Last active April 18, 2023 06:06
List of podcasts

Podcasts marked as (new) are still in review, and might be removed if they don't deliver.

Entertainment

  • SmartLess - Jason Bateman, Sean Hayes, Will Arnett
  • Conan O’Brien Needs A Friend - Team Coco & Earwolf
  • (new) The Problem With Jon Stewart

Localization

@flodolo
flodolo / focus.py
Last active February 28, 2023 17:12
Focus locales missing from Fenix
#! /usr/bin/env python3
import json
from urllib.parse import quote as urlquote
from urllib.request import urlopen
def main():
query = """
{
@flodolo
flodolo / gist:ee76904421ad7a820a65b690e27e2542
Created December 20, 2022 19:59
Analyze Fenix data with CSV
#!/usr/bin/env python3
"""
This script is used to check top locales for Fenix in specific countries,
and try to find a best match in Pontoon locales.
It expects a CSV file stored as "android_data.csv" from this query
https://sql.telemetry.mozilla.org/queries/89302
"""