Skip to content

Instantly share code, notes, and snippets.

View ThomasG77's full-sized avatar

Thomas Gratier ThomasG77

View GitHub Profile
@AtulKsol
AtulKsol / db_backup_commands.md
Last active March 23, 2026 03:02
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@bowin
bowin / node.js PassThrough stream.md
Last active May 18, 2025 18:05
Node.js Stream PassThrough Usage
const {PassThrough} = require('stream')
const fs = require('fs')

const d = new PassThrough()  

fs.createReadStream('tt2.js').pipe(d)  // can be piped from reaable stream

d.pipe(process.stdout)                 // can pipe to writable stream 
d.on('data', console.log) // also like readable
@elpaso
elpaso / qgis3_wsgi_server.py
Created October 5, 2017 07:22
A simple QGIS3 WSGI server experiment
#!/usr/bin/env python
# Simple QGIS 3 Server wsgi test
import signal
import sys
from cgi import escape, parse_qs
from urllib.parse import quote
# Python's bundled WSGI server
from wsgiref.simple_server import make_server
@nitanka
nitanka / create-ebs.yml
Last active January 12, 2023 16:40
Ansible: Adding EBS volume to an EC2 instance
---
- name: Creating a Volume
hosts: localhost
become: yes
tasks:
- name: Creating a Volume
ec2_vol:
aws_access_key: "{{ lookup('env', 'AWS_ACCESS_KEY_ID') }}"
aws_secret_key: "{{ lookup('env', 'AWS_SECRET_ACCESS_KEY') }}"
instance: '<instance-id>'
@jayphelps
jayphelps / package.json
Last active April 7, 2026 13:19
TypeScript output es2015, esm (ES Modules), CJS, UMD, UMD + Min + Gzip. Assumes you install typescript (tsc), rollup, uglifyjs either globally or included as devDependencies
{
"scripts": {
"build": "npm run build:es2015 && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:umd:min",
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015",
"build:esm": "tsc --module es2015 --target es5 --outDir dist/esm",
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs",
"build:umd": "rollup dist/esm/index.js --format umd --name YourLibrary --sourceMap --output dist/umd/yourlibrary.js",
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o yourlibrary.min.js -- yourlibrary.js && gzip yourlibrary.min.js -c > yourlibrary.min.js.gz",
}
}

documentation.js direction

I've been meditating on the direction of documentation.js going forward. Here's what I've decided on for now:

ground-up rebuild for modern javascript only

I'm going to rebuild documentation.js from the ground up, using a frontend that relies heavily on Flow annotations, and only supports export/import following. That means:

  • CommonJS import/export will no longer be supported
  • JSDoc types will no longer be supported
@HarryStevens
HarryStevens / .block
Last active September 13, 2020 07:01
Choropleth Sandbox
license: gpl-3.0
height: 700
@reywood
reywood / how-to.md
Last active January 4, 2026 21:28
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running python script

Sometimes a python script will simply hang forever with no indication of where things went wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward. Here's a way to see where the program is currently stuck.

Install gdb and pyrasite

Install gdb.

# Redhat, CentOS, etc
@Komzpa
Komzpa / gevel_postgis.md
Last active May 7, 2021 00:35
Visualize PostGIS index using Gevel in Postgres 9.6

Visualize PostGIS index using Gevel in Postgres 9.6:

git clone git://sigaev.ru/gevel
cd gevel
git checkout bd8b8b031a8049a6e7c18c00946bfbd99d75d27f
USE_PGXS=1 make
sudo USE_PGXS=1 make install
psql -f /usr/share/postgresql/9.6/contrib/gevel.sql