Skip to content
Bret Comnes edited this page Oct 26, 2022 · 18 revisions

Notes

Just a place to keep some notes.

Schema Notes

https://gist.github.com/bcomnes/608a93e3d90f6f57151765e1d3f1e876 https://gist.github.com/bcomnes/36cfdaf191b4733f2ed3bd90394c28bb

Auth stuff

https://medium.com/@alexishevia/storing-passwords-securely-with-postgresql-and-pgcrypto-87151a318998

CREATE EXTENSION pgcrypto;

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
   email TEXT NOT NULL UNIQUE,
   password TEXT NOT NULL
);
INSERT INTO users (email, password) VALUES (
  '[email protected]', 
  crypt('johnspassword', gen_salt('bf')) 
);
SELECT id 
  FROM users
 WHERE email = '[email protected]' 
   AND password = crypt('johnspassword', password);
id
----
  1
(1 row)
SELECT id 
  FROM users
 WHERE email = '[email protected]' 
   AND password = crypt('wrongpassword', password);
id
----
(0 rows)

SQL & Migrations

SQL patch updates

for example, if you want to insert or update column_to_update and return the whole row afterward you can do something like INSERT ... ON CONFLICT unique_key_column DO UPDATE column_to_update = EXCLUDED.column_to_update RETURNING *

See also https://www.postgresql.org/docs/15/sql-merge.html in PostgreSQL 15

Session notes

Full text search

Client side content extraction

https://www.youtube.com/watch?v=HiawfYnbX3Y

e2e encryption

CSS references

https://twitter.com/steve8708/status/1515413842657832964?s=12&t=UKrTFUOVUSTjQy8HOeiLlA

URL Cleaning

Email validation

Twitter avatars

I remember I had to fight it, I think it has to be max 400x400px, and upload it via the mobile web interface

Markdown

Component style helpers

Heroku build pack stuff