Skip to content

Instantly share code, notes, and snippets.

View zbraniecki's full-sized avatar

Zibi Braniecki zbraniecki

View GitHub Profile
@zbraniecki
zbraniecki / table.mjs
Last active February 5, 2020 18:55
ICU filtering
import Table from 'tty-table';
import json2csv from 'json-2-csv';
import fs from 'fs';
const MC = "/home/zbraniecki/projects/mozilla-unified";
function readFirefoxLocales() {
let source = fs.readFileSync(`${MC}/browser/locales/all-locales`, "utf8");
return source.split("\n").map(loc => {
if (loc === "") {
@zbraniecki
zbraniecki / README.md
Last active April 7, 2024 04:42
Rust <--> C/C++ FFI for newbies

As Gecko is moving toward more Rust code, the cases where Rust and C code interoperate will become more common.

This document is an attempt to ease the learning curve for engineers facing it for the first time. It assumes no prior experience with cross-language C interfaces (called FFI).

It also assumes that Rust code is already built into Gecko. If you need help with that, read Introducing Rust code in Firefox.

What can you transfer across the fence

@zbraniecki
zbraniecki / procedure.txt
Last active February 26, 2020 06:19
fluent-rs performance test against about:preferences in Firefox
Since we are caching resources after first run, to test performance, we need to restart the browser between each try.
Steps:
Parsing, old impl:
1) Apply the patchset from https://bugzilla.mozilla.org/show_bug.cgi?id=1560038 until `fluent-bindgen-rs`. Do not apply `fluent-swap-impls` or you'll lose ability to test JS impl.
2) Copy to memory the test.js
3) Start browser
4) Open browser console (ctrl+shift+j)
5) Paste the snippet and launch it
@zbraniecki
zbraniecki / Cargo.toml
Created December 2, 2019 22:30
Criterion in jsasparagus
[package]
name = "parser"
version = "0.1.0"
authors = ["Jason Orendorff <jason.orendorff@gmail.com>"]
edition = "2018"
[dependencies]
generated_parser = { path = "../generated_parser" }
ast = { path = "../ast" }
bumpalo = "2.6.0"
@zbraniecki
zbraniecki / command.sh
Created October 24, 2019 22:51
DTD hunt
rg "&([a-zA-Z][^;]+);" -g '*.xhtml' -g '*.xul' -g '*.inc' -l -c ./browser/ ./toolkit/ ./security/ ./layout/tools/ ./dom/base/ ./widget/ ./docshell/
@zbraniecki
zbraniecki / id-count.py
Last active September 13, 2019 21:54
find unused strings
import subprocess
import os
import re
exclude_formats = [
"*.dtd",
"*.properties",
]
include_formats = [
@zbraniecki
zbraniecki / emit.rs
Created August 26, 2019 17:30
annotate-snippets replacement for language-reporting emit.rs example
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
fn main() {
let source = r##"
(define test 123)
(+ test "")
()
"##;
@zbraniecki
zbraniecki / aggregate.py
Last active September 6, 2019 17:56
AWFY scripts
from arewefluentyet import data
import os
import subprocess
import json
from datetime import date, datetime, timedelta
# adjust this path to your local check-out of the gh-pages branch
REPO = "/Users/zbraniecki/projects/fluent/arewefluentyet.com/gh-pages"
MC = "/Users/zbraniecki/projects/mozilla-unified"
@zbraniecki
zbraniecki / add_likely_subtags.cpp
Last active September 19, 2019 17:06
Performance of ICU Locale parsing vs. unic-locale proposal
#include <stdio.h>
#include <chrono>
#include <vector>
#include <cstring>
#include "unicode/uloc.h"
std::vector<std::string> ids;
ids.push_back("en-US");
ids.push_back("en-GB");
@zbraniecki
zbraniecki / DOMOverlays rev2 perf
Last active April 12, 2019 23:56
DOMOverlays perf
{
const {DOMLocalization} = ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm");
let count = 10000;
let l10n = {
value: `Click on <img data-l10n-name="picture"/> to go to <a data-l10n-name="link"/>the website</a>.`
};
let elems = [];
for(let i = 0; i < count; i++) {
let elem = document.createElement("description");
let frag = MozXULElement.parseXULToFragment(`<img src="logo.png" data-l10n-name="picture"/><a href="www.mozilla.org" data-l10n-name="link"></a>`);