Skip to content

Instantly share code, notes, and snippets.

Edit your pg_hba.conf and set connections on local to trust for the duration of the upgrade.
/usr/pgsql-9.5/bin/pg_upgrade --old-bindir=/usr/pgsql-9.4/bin/ --new-bindir=/usr/pgsql-9.5/bin/ --old-datadir=/var/lib/pgsql/9.4/data/ --new-datadir=/var/lib/pgsql/9.5/data/
@v-thomp4
v-thomp4 / SimpleHTTPServerWithUpload.py
Created January 2, 2018 06:59 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@v-thomp4
v-thomp4 / Measure response time with curl
Created March 14, 2018 08:14 — forked from blackymetal/Measure response time with curl
How to measure request/response time with curl
curl -w "@curl-format.txt" -o /dev/null -s http://www.aduanacol.com
@v-thomp4
v-thomp4 / read-access.sql
Created May 11, 2018 12:28 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@v-thomp4
v-thomp4 / gist:d85558771526e9ec8642a26f14418d1e
Created May 15, 2018 10:12
Elasticsearch: change cluster health from yellow to green
curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/_settings' -d '
{
"index" : {
"number_of_replicas" : 0
}
}'
pg_restore --verbose --clean --no-acl --no-owner -c -h db_host -U postgres -d db_name db_file.dump

rebase last 5 commits

git rebase -i HEAD~5  
git rebase --edit-todo  
(drop)  
git rebase --continue  
git push --force origin master  
@v-thomp4
v-thomp4 / gist:1885718025a11ed3a798fbf45207c0ec
Created June 2, 2018 07:35
Setup Postgres Replication with Hot Standby
Configuring the primary server
$ sudo -u postgres /usr/pgsql-9.5/bin/createuser -U postgres repuser -P -c 5 --replication
Create the archive directory
$ mkdir -p /var/lib/postgresql/9.5/main/mnt/server/archivedir
Edit pg_hba.conf
$ nano /etc/postgresql/9.5/main/pg_hba.conf
# Allow replication connections
host replication repuser ip_standby_server/32 md5
worker_processes 2;
error_log /var/log/nginx/error.log info;
events {
worker_connections 1024;
}
http {
init_by_lua '
function split(inputstr, sep)
@v-thomp4
v-thomp4 / gist:4f90fe0ec906d9607f605da4c3bd05f7
Created July 4, 2018 10:58
Fix Rocketchat Your database migration failed
ERROR! SERVER STOPPED
our database migration failed:
Database locked at version: 124
Fix:
use rocketchat
db.migrations.update({_id: 'control'},{$set:{locked:false,version:125}})