Skip to content

Instantly share code, notes, and snippets.

View zbraniecki's full-sized avatar

Zibi Braniecki zbraniecki

View GitHub Profile
@zbraniecki
zbraniecki / intro_interactive_js.md
Last active November 11, 2025 21:22
ICU4X 2.1 Interactive Intro

Interactive Date Picker (JS)

In this tutorial, you will learn how to build an end-to-end application using ICU4X to format a date and time with some default locales and additional locales loaded dynamically.

1. Installing ICU4X

Installing dependencies is always your first step.

We recommend using CodePen to follow along. To load ICU4X into CodePen, you can use this snippet in the JavaScript editor:

@zbraniecki
zbraniecki / Boa 0.21
Last active November 11, 2025 18:40
Temporal Benchmarks between V8, SM & Boa
Temporal benchmark starting...
TimeZones: UTC, America/Los_Angeles, Europe/Warsaw, Asia/Shanghai
Calendars: iso8601, gregory, hebrew, chinese, japanese, buddhist, persian
All results are higher-is-better (ops/sec).
Offset lookup via ZDT (proxy for getOffset) | ops/sec mean=1025339 median=1024000 p95=1028016 (n=6)
ZonedDateTime.from Instant+TZ | ops/sec mean=887657 median=885622 p95=891646 (n=6)
ZonedDateTime.add across DST | ops/sec mean=470945 median=471482 p95=474899 (n=6)
PlainDate dateAdd (months/years/leap) | ops/sec mean=1499564 median=1502270 p95=1506575 (n=6)
PlainDateTime since/until (varied units) | ops/sec mean=628153 median=627139 p95=630154 (n=6)
ZonedDateTime.round (minute/hour/day) | ops/sec mean=856836 median=859498 p95=868026 (n=6)
@zbraniecki
zbraniecki / PlatformIntlApple.cpp
Last active February 7, 2024 01:26
Hermes ICU4X
// https://github.com/facebook/hermes/blob/main/lib/Platform/Intl/PlatformIntlApple.mm#L319-L353
vm::CallResult<std::vector<std::u16string>> canonicalizeLocaleList(
vm::Runtime &runtime,
const std::vector<std::u16string> &locales) {
// 1. If locales is undefined, then
// a. Return a new empty List
// Not needed, this validation occurs closer to VM in 'normalizeLocales'.
// 2. Let seen be a new empty List.
std::vector<std::u16string> seen;
@zbraniecki
zbraniecki / sizes.txt
Last active April 17, 2023 21:21
ICU4X 1.2 Segmentation (utf16) sizes
╭────┬────────────────────────┬──────┬─────────┬────────────────╮
│ # │ name │ type │ size │ modified │
├────┼────────────────────────┼──────┼─────────┼────────────────┤
│ 0 │ ar-icu4c-line.txt │ file │ 22.7 KB │ 3 hours ago │
│ 1 │ ar-icu4c-word.txt │ file │ 48.6 KB │ 3 hours ago │
│ 2 │ ar-icu4x-line-utf8.txt │ file │ 23.8 KB │ 3 hours ago │
│ 3 │ ar-icu4x-line.txt │ file │ 22.9 KB │ 3 hours ago │
│ 4 │ ar-icu4x-word-utf8.txt │ file │ 50.5 KB │ 3 hours ago │
│ 5 │ ar-icu4x-word.txt │ file │ 48.6 KB │ 3 hours ago │
│ 6 │ ar.txt │ file │ 35.1 KB │ 3 hours ago │
@zbraniecki
zbraniecki / results.txt
Created November 2, 2022 05:51
ICU4X Result<(), _> cases
/Users/zibi/projects/icu4x〉rg 'Result<\(\)' -g "!{ffi/**}" -g "!{coverage/**}" ./ 11/02/2022 08:50:06 AM
./components/collections/src/codepointinvlist/cpinvlist.rs
864: fn test_serde_with_postcard_roundtrip() -> Result<(), postcard::Error> {
./components/collections/src/codepointtrie/cptrie.rs
996: fn test_serde_with_postcard_roundtrip() -> Result<(), postcard::Error> {
./components/list/src/provider.rs
274: ) -> Result<(), DataError> {
@zbraniecki
zbraniecki / test.js
Last active November 8, 2022 03:57
Localizable Manifest Options Size Comparison
const fs = require('fs');
const display = false;
const pretty = false;
let input = {
"title": {
"display": "Lorem Ipsum",
},
@zbraniecki
zbraniecki / structure.txt
Last active December 15, 2021 05:42
ICU4X Licenses (Dec 2021)
## Current Library Structure in the repo
//
├─ components/
│ ├─ component1/
│ │ ├─ src/
│ ├─ component2/
│ │ ├─ src/
│ │ ├─ data/
│ │ │ ├─ from_unicode/
@zbraniecki
zbraniecki / init.vim
Created November 17, 2021 15:42
nvim 0.6 config 2021-11-17
call plug#begin('~/.vim/plugged')
" Collection of common configurations for the Nvim LSP client
Plug 'neovim/nvim-lspconfig'
" Completion framework
Plug 'hrsh7th/nvim-cmp', { 'branch': 'main' }
" LSP completion source for nvim-cmp
Plug 'hrsh7th/cmp-nvim-lsp', { 'branch': 'main' }
@zbraniecki
zbraniecki / zibi.ts
Created February 1, 2021 16:41
MF2.0 Data Model
// Changed NumberLiteral to be a float+precision
// Added Variant::default
// Separated Arguments and Options on a FunctionReference
// Added KeyValuePair used in FunctionReference and maybe in MessageReference
// Added optional MessageReference if we decide to go for it
export type Message = MessageValue;
export type MessageValue = Single | Multi;
@zbraniecki
zbraniecki / datetime.cpp
Created January 25, 2021 01:07
FFI for ICU4X example
class DateTimeFormat {
public:
Result<DateTimeFormat, ()> tryNew(string aLocale, options aOptions);
string format(date aDate);
protected:
DateTimeFormat(string aLocale, ffi::DateTimeFormatData aData);
UniquePtr<ffi::DateTimeFormatData> mData;
};