Stream of Consciousness

Why I Created This Page

I sometimes want to note something or write something down for the future, but the thing that I want to write about is not long enough to warrant writing a full notes page on. This page is designed to be a microblogging page where I can insert custom HTML/CSS/JavaScript or a lexical editor.

View Stream Options

I wish you could change the theme of vscode depending on what kind of file you were looking at

1

Car Shipping Cost


The average cost for auto shipping within the continental US is around 1,000 USD, with the lowest flirting near 700-750 USD and the highest average price being in the 1,200-1,300 USD neighborhood. In general, the per-mile average for automobile shipping is around 0.60 USD/mile for distances over 1,000 miles. Shorter routes cost more per mile.
American Auto Shipping - How Much Does it Cost to Ship a Car

From

To

Miles

Cost

Birmingham, AL

Los Angeles, CA

2,038

$1,222

New York, NY

Los Angeles, CA

2,789

$1,673

Miami, FL

Seattle, WA

3,301

$1,980

Birmingham , AL

San Francisco, CA

2,326

$1,395

Car Depreciation


  • Driving the car off of the lot generally results in about 10% depreciation.
  • After that fast initial drop the depreciation progresses a bit more slowly - often by about 10 to 15 percent per year. According to some experts, mileage depreciation is about $0.08 a mile, but depreciation is more commonly measured in years than miles.
1

Foreign Keys Reminder


A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table. We say this maintains the referential integrity between two related tables.
PostgreSQL Docs
  • You need to add ON DELETE CASCADE when you want the referencing row to be deleted when the referenced row is deleted.
  • If the two tables are independent, then you can add ON DELETE RESTRICT or ON DELETE NO ACTION
1

Creating Search Reference


  1. Create a table to hold what you want to search.
  2. Add a document column (the column which holds the text that you want to search for).
  3. Add a column search tsvector GENERATED ALWAYS AS (to_tsvector('english',document) || ' ') STORED NOT NULL
  4. Add a column for embedding if you want to include embeddings.
CREATE TABLE <search_table> (
...
document TEXT NOT NULL,
search tsvector GENERATED ALWAYS AS (
to_tsvector('english',document) || ' '
) STORED NOT NULL,
embedding vector(1536) NOT NULL, -- number inside vector() should be the length of the vector
...
);

Creating Indexes


  1. To create an index for string similarity matching on the document column, use a GIST index or GIN index - these are recommended by pgtrm
  2. To create an index for the search column, add a GIN index to speed up searches.
  3. To create an index for the embedding column, add a hnsw index for the embedding column.
    1. The <option> below can either be:
      1. vector_ip_ops: Inner Product
      2. vector_cosine_ops: Cosine Distance
      3. vector_l1_ops: L1 Distance
      4. bit_hamming_ops: Hamming Distance
      5. bit_jaccard_ops: Jaccard Distance
CREATE INDEX text_sim_index ON <search_table> USING GIST (document);
CREATE INDEX search_index ON <search_table> USING GIN (search);
CREATE INDEX embedding_index ON <search_table> USING hnsw (<embedding_column_name> <option>);
1

Lexical Reminder


How Lexical copies Lexical Nodes:

  • Copy:
    • copyToClipboard: Lexical content serialized with $getLexicalContent
  • Paste:
    • $insertDataTransferForRichText: if the DataTransfer data has application/x-lexical-editor data, then that data is JSON.parsed, nodes are generated with $generateNodesFromSerializedNodes, and inserted with $insertGeneratedNodes
1

You should only use <output for="" />, with the for attribute, when you want the value of the <input> to be placed into the output element. This can cause problems.

1

PostgreSQL


  • When you add a FOREIGN KEY, make sure that you include ON DELETE CASCADE if you intend the row in the child table to be deleted when the referenced row is deleted.
1

CSS Reminder


  • Whenever using position: sticky, you probably need to increase the z-index of the component and set opacity: 1 so that the sticky content is not partially covered up by content on the page.
2

Test Stream Consciousness Post with Custom HTML

Enter a modulo divided and dividend in the inputs below and click submit to calculate the modulus.

2

Test Stream of Consciousness Post with Lexical Editor

0