Skip to content

Instantly share code, notes, and snippets.

@jimathyp
jimathyp / postgres.md
Last active November 2, 2022 04:05
Postgres joins

Common SQL

SQL is declarative, tell what result we want, not how to do it. The DB engine/optimizer does that.


CTE common table expressions

eg

Excel Pivot Tables

Pivot tables are a way of creating filters and aggregations, and Pivot Charts can be made from the Pivot Table.

Primary advantage is the ease of which you can change the aggregation (and the resulting chart).

For example, you can easily select a time period, or filter only for a particular attribute.

They are particularly good for exploring data. Especially Pivot Charts - you can set up the title and axes labels automatically, so you can easily change what you are displaying.

Git config

Updating a Personal Access Token (PAT)

git config --list
git config --get remote.origin.url

Simplest (but unsecure) is to set remote.origin.url=

Git Branching

Creating

$ git checkout -b iss53
Switched to a new branch "iss53"

This is shorthand for:

IP of the virtual WSL ethernet interface

(actually the CIDR without the mask)

ip addr show eth0 | grep -oP '(?<=inets)d+(.d+){3}'

  1. get interface

WSL Drives in Windows

\wsl Opens C:\WSL that contains the Windows folders for each distribution

\wsl$ Opens a Network folder that contains the distribution disks mounted as network folders

Jupyter Notebook Issues

Particular to running in WSL.

The usual way to start is with

jupyter notebook

But if error

XWindows Configuration for WSL

Windows 11 will have "WSLg"

https://github.com/microsoft/wslg WSLg is short for Windows Subsystem for Linux GUI and the purpose of the project is to enable support for running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience.

PSQL usage

creating tab-delimited output for file

psql -F '\t' -c "select from x"-o output.tab

# -F wants the actual literal character

# Need to use an 'actual' tab (or newline)