Skip to content

Instantly share code, notes, and snippets.

View GauBen's full-sized avatar
📅
Working on the next social network

Gautier Ben Aïm GauBen

📅
Working on the next social network
View GitHub Profile
import { ResultOf } from 'gql.tada';
import {Constants} from '~/ContentEditor/ContentEditor.constants';
import { ContentEditorFragment } from './fragments.js';
export const adaptSections = (sections: ResultOf<typeof ContentEditorFragment>['sections']) => {
return sections
.map(section => {
const sourceFieldSets = section.name === 'metadata' ?
section.fieldSets.filter(fieldSet => !fieldSet.fields.some(f => f.readOnly)) :
section.fieldSets;
@GauBen
GauBen / i-m-working-on-content-versioning-fluffy-lampson.md
Created July 22, 2026 09:35
Abstract jContent implementation details out of content-versioning

Abstract jContent implementation details out of content-versioning

Context

content-versioning is an external Jahia UI module that renders a read-only "Version History" side-by-side view inside Content Editor by reusing jContent's own form machinery (FormBuilder, the editor contexts, ContentEditorFragment). jContent was never designed to be consumed externally, so its internals bleed into the module. The worst offender: the module re-implements jContent's private adaptSections (field renaming, ce:systemName mapping, section filtering) in adaptSnapshotForm.ts, with a literal "Copied from jcontent" comment.

import { type InspectColor, styleText } from "node:util";
type StyleText = ((
text: string | TemplateStringsArray,
...args: unknown[]
) => string) & { [key in InspectColor]: StyleText };
function createStyleText(...styles: InspectColor[]): StyleText {
return new Proxy(
(text: string | TemplateStringsArray, ...args: unknown[]) =>
module.exports = {
name: 'plugin-cache-download',
factory: (require) => {
const { BaseCommand } = require('@yarnpkg/cli');
const { Command } = require('clipanion');
const { Project, Configuration, Cache, ThrowReport } = require('@yarnpkg/core');
class CacheDownloadCommand extends BaseCommand {
static paths = [['cache', 'download']];
<script lang="ts">
import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
import { createEventDispatcher, onMount } from 'svelte';
/** A simple list of strings for now, but we might need more complicated structures in the future. */
export let options: string[];
/** Input element to attach the datalist to. */
export let input: HTMLInputElement;
/**
* This module contains cryptography functions. While we strive to comply to all
* the best practices, we are not cryptographers. Use at your own risk.
*
* We use the `pbkdf2` algorithm to hash passwords because it works in the
* browser. It is considered secure by the RFC8018 (published in 2017), but most
* sources recommend using `argon2id` instead.
*
* @module
* @see https://datatracker.ietf.org/doc/html/rfc8018
@GauBen
GauBen / wip.ts
Last active April 17, 2021 16:39
function loop<T>(arr: T[], fn: (a: T, i: Number, arr: T[]) => string) {
return arr.reduce((a, b, i, arr) => a + fn(b, i, arr), '');
}
function escapeHtml(str: string)
{
const map =
{
'&': '&amp;',
'<': '&lt;',
import os
import sys
import matplotlib.pyplot as plt
import matplotlib.image
import scipy.ndimage as ndimage
import numpy as np
width, height = 1280, 720
grid = 20
# Difference (norm2) between old and new pixels to consider it's not the background