Skip to content

Instantly share code, notes, and snippets.

View inexorabletash's full-sized avatar

Joshua Bell inexorabletash

View GitHub Profile
@inexorabletash
inexorabletash / @ Indexed DB - N-Dimensional Select.md
Last active April 16, 2024 20:38
Indexed DB - N-dimensional selection

Indexed DB - N-Dimensional Selection

The problem

We have an index with keys of the form:

[ dim1, dim2, dim3, ... ]

e.g. created with:

@inexorabletash
inexorabletash / @ IndexedDB Full Text Search (Proof of Concept).md
Last active March 19, 2024 13:08
IndexedDB Full Text Search (Proof of Concept)

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

@inexorabletash
inexorabletash / @WHATWG-style logos.md
Last active January 25, 2024 01:07
In another universe...
@inexorabletash
inexorabletash / @ OBSOLETE IndexedDB Promises.md
Last active January 19, 2024 05:50
IndexedDB with Promises Hackery
@inexorabletash
inexorabletash / @ Indexed DB URLs via Service Workers.md
Last active December 20, 2023 01:29
Indexed DB URLs via Service Workers

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
inexorabletash / idbkeyrange_forprefix.js
Last active October 19, 2023 15:23
Helper for creating an IDBKeyRange for all keys with a given prefix
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Basic p(r)olyfill for proposed feature
// This defines no successor of empty arrays, so the range for prefix
// [] or [[],[]] has no upper bound.
// An alternate definition would preclude adding additional nesting,
// so the range for prefix [] would have upper bound [[]] and the
// range for prefix [[], []] would have upper bound [[], [[]]].
@inexorabletash
inexorabletash / ansi_colors
Created February 20, 2014 20:30
Bash color utilities
#!/usr/bin/env bash
# Usage:
# echo -e "... $(text-style style ...) ..."
# echo -e "... $(text-reset) ..."
# echo -e "... $(text-color r g b) ..."
# echo -e "... $(background-color r g b) ..."
#
# Where:
# styles:
@inexorabletash
inexorabletash / @ Indexed DB - N-Dimensional Select V2.md
Last active July 18, 2022 11:03
@ Indexed DB - N-Dimensional Selection V2

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);
@inexorabletash
inexorabletash / @ Intl.Segmenter polyfill.md
Last active January 5, 2021 17:53
Intl.Segmenter polyfill

Following proposal by @littledan

THIS NO LONGER MATCHES THE PROPOSED API AND SHOULD NOT BE USED

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

Caveats:

@inexorabletash
inexorabletash / aliens_map.txt
Last active June 1, 2020 03:06
Aliens: The Computer Game (Activision) - Map
║ ═ ╔ ╗ ╚ ╝ ╠ ╣ ╦ ╩ ╬ -- normal
│ ─ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼ -- infested
Save the Marines:
╔═╦╦═╦╦═╗╔═╦╦═╗
╠╗╠╬═╝╚╦╩╣╔╝╚╗╚╗
║║║╚╗╔╦╝╔╬╝╔═╬═╝
╚╝╚═╩╝╚═╣╚═╣╔╩╦╗
║╔╗║╚╦╝║