Skip to content

Instantly share code, notes, and snippets.

SERVER=partisipa-staging.catalpa.build
DATABASE=partisipa_db
ssh_server := ssh root@${SERVER}
fetchdatabase :
$(ssh_server) rm -rf /tmp/pg_data_$(shell date -I)_$(shell hostname)
$(ssh_server) pg_dump --compress=0 --format=directory postgresql:///$(DATABASE) -f /tmp/pg_data_$(shell date -I)_$(shell hostname)
rsync --archive --compress --del root@${SERVER}:/tmp/pg_data_$(shell date -I)_$(shell hostname)/ ./source/ || true
$(ssh_server) rm -rf /tmp/pg_data_$(shell date -I)_$(shell hostname)
## apt installs:
git
gcc
pkg-config
## Install pyenv
Following [pyenv-installer](https://github.com/pyenv/pyenv-installer)
@joshbrooks
joshbrooks / 00_Topology Simplification.md
Last active May 6, 2022 08:52
Topology Simplification

Making Use of Topology

This runs on a restored dird_db from a Docker container, postgis:postgis/14-3.2; I run this as docker run -P ghcr.io/joshbrooks/openly_dird_prod

Pervious versions of postgis run into trouble on the topology building

First create the SimplifyEdgeGeom function: (https://gist.github.com/leplatrem/5729022) This wraps ST_ChangeEdgeGeom in error handling in cases of ugliness

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joshbrooks
joshbrooks / playwright.sh
Last active September 20, 2021 14:26
Collection of useful things to do with playwright
# Create and Enter your venv (if not already done)
python -m venv env
. env/bin/activate
# Install playwright
pip install playwright
# Install the chromium browser runner

Extracting data from OpenStreetMap into a Postgres db

1. Download PNG data

wget https://download.geofabrik.de/australia-oceania/papua-new-guinea-latest.osm.pbf

2. Clone the openstreetmap-carto dir

git clone git://github.com/gravitystorm/openstreetmap-carto.git --depth 1

@joshbrooks
joshbrooks / backup_rebuild.py
Created August 12, 2021 02:41
This is a single file class to do a backup; rsync that backup over to a local dir; and load that as initial data in a postgis container
#!/usr/bin/env python
import docker
import logging
from docker import DockerClient
import time
import subprocess
import sys
from dataclasses import dataclass
@joshbrooks
joshbrooks / blocktrans.md
Last active September 29, 2020 02:58
Translation-examples

Positional Text

You can include a placeholder to add for example user name, and in translations where word order changes

output = _('Today is %(month)s %(day)s.') % {'month': m, 'day': d}
#!/bin/bash
DOWNLOADS=~projectbank/mimu
PROJECT_DIR=/var/www/projectbank/source/projectbank
SCHEMA="mimu"
cd ${DOWNLOADS}
for file in *.zip
do
unzip -o ${file}
@joshbrooks
joshbrooks / estrada-reporting-output.md
Last active January 10, 2020 14:06
A SQL query to generate a table

Inputs

Takes 3 tables. One is a list of attr One is a list of road_code One is a list of surveys

Expected output: