Skip to content

Instantly share code, notes, and snippets.

View bdelacretaz's full-sized avatar

Bertrand Delacretaz bdelacretaz

View GitHub Profile
@bdelacretaz
bdelacretaz / test-decider.py
Created October 14, 2026 12:47
Testing the Mapika/decider model
# See https://github.com/Mapika/decider
#
# Before running this on macosx:
# pip install decider
# pip install "decider-ai[metal]"
import time
from decider.infer import Decider
# bf16 on CUDA (about 4 GB), float16 on MPS, float32 on CPU
@bdelacretaz
bdelacretaz / PullingPool.java
Last active January 6, 2026 22:46
Example thread pool that pulls tasks from a Supplier
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
// Example of a thread pool that pulls tasks from a Supplier
public class PullingPool {
public static void main(String[] args) throws Exception {
final int nThreads = (int) (Math.random() * 4) + 2;
final int nTasks = (int) (Math.random() * 45) + 5;
@bdelacretaz
bdelacretaz / orama-similarity-search.html
Last active November 8, 2024 13:57
Client-side similarity search using the orama vector database
<!doctype html>
<html>
<head>
<style>
.error {
font-weight: bold;
color: red;
}
@bdelacretaz
bdelacretaz / webllm-articles-similarity.html
Created October 29, 2024 19:28
Playing with WebLLM: article titles similarity
<!doctype html>
<html>
<head>
<script>
webLLMGlobal = {};
</script>
<style>
.error {
font-weight: bold;
@bdelacretaz
bdelacretaz / webllm-test.html
Created October 22, 2024 15:45
WebLLM test page
<!doctype html>
<html>
<head>
<script>
webLLMGlobal = {};
</script>
<style>
.error {
font-weight: bold;
@bdelacretaz
bdelacretaz / sync-xhr.html
Last active June 11, 2024 09:52
HTML page that tests Synchronous XHR
<!DOCTYPE html>
<html lang="en">
<head>
<title>Testing Sync XHR</title>
</head>
<body>
<h1>Testing <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest_API/Synchronous_and_Asynchronous_Requests">Sync XHR</a></h1>
<div id="msg">This is the msg</div>
@bdelacretaz
bdelacretaz / embedded-doap.html
Created September 8, 2023 09:27
Example embedding DOAP data in HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example DOAP embedded in HTML</title>
<script type="application/asf.doap+xml">
<rdf:RDF xml:lang="en"
xmlns="http://usefulinc.com/ns/doap#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:asfext="http://projects.apache.org/ns/asfext#"
<html>
<body>
<p>Load this page with <code>?ok=yes+it+works</code> to test it.</p>
<p>Search parameters: <b id="results"/></p>
<script>
const p = new URLSearchParams(window.location.search);
document.querySelector('#results').textContent = p.get('ok');
</script>
</body>
</html>
// List custom element names registered in the current browser page
console.log(
[...new Set([].map.call(
document.querySelectorAll('*'),
el => el.nodeName.toLowerCase()))
].filter(
customElements.get.bind(customElements)
)
.sort()
)
// @ts-check
const { test, expect } = require('@playwright/test');
test.beforeEach(async ({ page }) => {
await page.goto('https://demo.playwright.dev/todomvc');
});
const TODO_ITEMS = [
'buy some cheese',
'feed the cat',