Skip to content

Instantly share code, notes, and snippets.


Joshua Bell inexorabletash

View GitHub Profile
inexorabletash / test.html
Created Jun 30, 2020
TextDecoder Performance Test
View test.html
<!doctype html>
<meta charset=utf-8>
<title>TextDecoder Performance Test</title>
setTimeout(_ => {
const encoder = new TextEncoder();
const arrays = [];
for (let j = 0; j < 512; ++j) {
for (let i = 0; i < 128; ++i) {
inexorabletash / aliens_map.txt
Last active Jun 1, 2020
Aliens: The Computer Game (Activision) - Map
View aliens_map.txt
║ ═ ╔ ╗ ╚ ╝ ╠ ╣ ╦ ╩ ╬ -- normal
│ ─ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼ -- infested
Save the Marines:
inexorabletash / @ IndexedDB Full Text Search (Proof of Concept).md
Last active Sep 11, 2021
IndexedDB Full Text Search (Proof of Concept)
View @ IndexedDB Full Text Search (Proof of Concept).md

This demonstrates the implementation of full text search for documents in Indexed DB.

  • Word-breaking and stemming is used to create a list of terms for each document.
  • Document records are annotated with the list of terms when added to the database.
  • A multi-entry index on the list of terms is populated.
  • A query is similarly processed into a list of terms.
  • A join over the terms is implemented using multiple cursors on the index.

The necessity of annotating records with the word list to populate the index is a limitation of the current Indexed DB API. A feature request to support custom

View @ Intl.Segmenter

Following proposal by @littledan


Just proof-of-concept. Do not use in production.


inexorabletash / @ Indexed DB - N-Dimensional Select
Last active Jul 23, 2021
@ Indexed DB - N-Dimensional Selection V2
View @ Indexed DB - N-Dimensional Select

Indexed DB - N-Dimensional Selection (V2)

This is a redo of the solution over in Indexed DB - N-Dimensional Selection but with a revised "API". The sample here takes a query in the form of an array of IDBKeyRange instances (or null), e.g.

select(index, [IDBKeyRange.bound(5, 7), null, IDBKeyRange.lowerBound(15000)], callback, complete);
View @ Indexed DB URLs via Service

URLs into Indexed DB, via Service Workers

Let's say you're using Indexed DB for the offline data store for a catalog. One of the object stores contains product images. Wouldn't it be great if you could just have something like this in your catalog page?

<img src="indexeddb/database/store/id">
inexorabletash / @ Indexed DB - N-Dimensional
Last active Sep 5, 2021
Indexed DB - N-dimensional selection
View @ Indexed DB - N-Dimensional

Indexed DB - N-Dimensional Selection

The problem

We have an index with keys of the form:

[ dim1, dim2, dim3, ... ]

e.g. created with:

View @ Indexed DB Transactionless

Transactionless Indexed DB

Status: Initial thought experiment. Feedback welcome.

There are times when Indexed DB's transaction-centric API is too heavyweight:

View Microsoft.PowerShell_profile.ps1
# Custom prompt
function prompt {
write-host -NoNewLine -ForegroundColor Red $pwd
# Current git branch name
$branch = git rev-parse --abbrev-ref HEAD
if ($branch) {
write-host -NoNewLine -ForegroundColor Green (' [' + $branch + ']')