This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE IF NOT EXISTS mytable | |
| ( | |
| pk_id serial PRIMARY KEY, | |
| geom geometry(Polygon,3857), | |
| geohash text | |
| ); | |
| CREATE INDEX IF NOT EXISTS mytable_geohash_idx | |
| ON mytable ( ST_GeoHash(ST_Transform(geom,4326), 3 ) ); -- 3 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #tested on ubuntu 20.04.3 | |
| sudo apt list --upgradable | |
| #create sudoer | |
| sudo adduser devel | |
| sudo usermod -aG sudo devel | |
| sudo apt install vim | |
| sudo apt install python3.9 | |
| #add new postgres in APT from https://www.postgresql.org/download/linux/ubuntu/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # vim:set fileencoding=utf-8 sw=2 ai: | |
| import sqlite3 | |
| import datetime | |
| import re | |
| SQL = ''' | |
| select | |
| name, version, time, author, text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |