Skip to content

Instantly share code, notes, and snippets.

View dgaubert's full-sized avatar

Daniel G. Aubert dgaubert

View GitHub Profile
@dgaubert
dgaubert / cheatsheet-postgresql-monitoring.md
Last active September 13, 2023 07:56
Cheatsheet: PostgreSQL Monitoring

Cheatsheet: PostgreSQL Monitoring

To query these metrics, you must be logged into PostgreSQL as a user that has read access to pg_stat_database

Useful psql commands

  • Check version of PostgreSQL: SELECT version();
  • Show location of postgresql.conf file (requires superuser privileges): SHOW config_file;
  • Show location of data directory (requires superuser privileges): SHOW data_directory;
  • Show location of log directory (may be a path relative to data directory, requires superuser privileges): SHOW log_directory;
const { promisify } = require('util')
function timeout (time, callback) {
if (time > 1000) {
throw new Error('Limit 1000')
}
if (time > 500) {
return callback(new Error('Limit 500'))
}

Maps API: getting started

Basic concepts:

  • What's a map?: User's data (sql/analyses) + basemap + pop-ups + dataviews

Components:

  • Browser (carto[JS|VL]), cdn, nginx, varnish, maps-api, batch-api, redis-metadata, user's database

Map Instatiation Workflow: Map Config (request) & Layergroup (response):

@dgaubert
dgaubert / README.md
Last active October 4, 2018 16:43
overviews vs aggregation vs original data

Performance comparison beetwen overviews vs aggregation vs original data

Original table has 700k points. To compare load times, select a layer (You must be connected to the VPN) and open developer tools and check console output

Comparison beetwen overviews vs aggregation vs original data with turbocarto applied

Original table has 700k points. To compare load times, select a layer (You must be connected to the VPN) and open developer tools and check console output

Test: tests/e2e/data/observatory/enrichment/test_enrichment.py::TestEnrichment::test_points_and_private_data

Test is failing in both branches because of the same reason: do_area area doesn't match between enriched vs expected. The easiest solution is to update fixture to match with current enriched reault.

  • Branch enrichment

    • Enriched DataFrame

          BLOCKGROUP  MLTCY7224  RSGCY7224       do_area                    geometry
      
@dgaubert
dgaubert / README.md
Created December 30, 2022 13:02
Deferred Fetch

Get started

$ npm i

Run

$ node app.js
@dgaubert
dgaubert / inspect.ts
Created August 31, 2023 16:09
Console Inspect
// eslint-disable-next-line no-console
console.log((await import('util')).inspect(myObject, { showHidden: false, depth: null, colors: true }))

Architecture

Notes about I'd architecture a new long-life project.

TL;DR

  1. Monolith first, split when needed.
  2. Folder structure by feature, component, or service. Avoid layers, file category, or same class.
  3. Place tests along code. Don't use a separate folder
  4. Avoid long nested paths for endpoints. Context should be in the JWT