Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Sebastian Webber sebastianwebber

🏠
Working from home
View GitHub Profile
@sebastianwebber
sebastianwebber / docker-compose.yml
Last active Jun 13, 2020
basic docker-compose for grafana and prometheus
View docker-compose.yml
version: '3.1'
volumes:
prometheus_data: {}
grafana_data: {}
services:
prometheus:
image: prom/prometheus
volumes:
@sebastianwebber
sebastianwebber / 0-update-test.sql
Last active May 9, 2018
update tests - to validate a pRest implementation
View 0-update-test.sql
-- tuning used: https://www.pgconfig.org/#/tuning?total_ram=10&max_connections=100&environment_name=WEB&pg_version=10&os_type=Unix&arch=x86-64&drive_type=SSD&share_link=true
-- mbp pro 15", 500gb ssd, 16gb ram, i7 2,9ghz processor
\timing on
\pset null ~
\set max_rows 1000
DROP TABLE IF EXISTS load_test;
create table load_test (id serial primary key, name text, birth_date date, age int);
@sebastianwebber
sebastianwebber / compare-pg-lsn.rb
Last active Mar 20, 2018
Compare PostgreSQL LSN in ruby
View compare-pg-lsn.rb
# select pg_xlog_location_diff('951A/EA0F8000', '9518/1ECB6000');
# super_db=# select pg_xlog_location_diff('951A/EA0F8000', '9518/1ECB6000');
# pg_xlog_location_diff
# -----------------------
# 12000174080
# (1 row)
# super_db=# select pg_xlogfile_name('951A/EA0F8000'), pg_xlogfile_name('9518/1ECB6000');
# -[ RECORD 1 ]----+-------------------------
# pg_xlogfile_name | 000000030000951A000000EA
@sebastianwebber
sebastianwebber / create-ec2-instance-playbook.yml
Last active Oct 30, 2020
Create a EC2 instance with ansible-playbook
View create-ec2-instance-playbook.yml
---
- hosts: localhost
connection: local
vars:
gather_facts: False
vars:
keypair: "my-keypair-name"
instance_type: m4.large
security_group:
- "vpc-group-1"
@sebastianwebber
sebastianwebber / teste.txt
Created Apr 1, 2017
teste com o search_path
View teste.txt
sebastian=# create schema esquema_a;
CREATE SCHEMA
sebastian=# create schema esquema_b;
CREATE SCHEMA
sebastian=# create schema esquema_c;
CREATE SCHEMA
sebastian=# create schema esquema_d;
CREATE SCHEMA
sebastian=# create schema esquema_e;
CREATE SCHEMA
@sebastianwebber
sebastianwebber / vagrantfile.rb
Last active Feb 14, 2017
Ubuntu 16.04 vagrantfile with postgresql 9.5
View vagrantfile.rb
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
$script = <<SCRIPT
sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -c | awk '{print $2}')-pgdg main" > /etc/apt/sources.list.d/pgdg.list
@sebastianwebber
sebastianwebber / ssh-forward-clipboard.md
Created Feb 7, 2017 — forked from dergachev/ssh-forward-clipboard.md
Forward your clipboard via SSH reverse tunnels
View ssh-forward-clipboard.md

Exposing your clipboard over SSH

I frequently administer remote servers over SSH, and need to copy data to my clipboard. If the text I want to copy all fits on one screen, then I simply select it with my mouse and press CMD-C, which asks relies on m y terminal emulator (xterm2) to throw it to the clipboard.

This isn't practical for larger texts, like when I want to copy the whole contents of a file.

If I had been editing large-file.txt locally, I could easily copy its contents by using the pbcopy command:

@sebastianwebber
sebastianwebber / base_backup.sh
Last active Dec 23, 2016
pg_basebackup for slave
View base_backup.sh
## postgres=# create user replicator replication password 'teste';
pg_basebackup -U replicator -h 192.168.100.100 -D /var/lib/pgsql/9.3/data --write-recovery-conf --xlog-method=stream --progress --verbose --checkpoint=fast
@sebastianwebber
sebastianwebber / .vimrc
Created Nov 24, 2016
vimrc for customers
View .vimrc
:set bg=dark
:set nu
:set ic
:set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
@sebastianwebber
sebastianwebber / top-indexes-pgsql-lld.sql
Created Nov 10, 2016
Lista os indices para uso do LLD no zabbix
View top-indexes-pgsql-lld.sql
-- Based on https://wiki.postgresql.org/wiki/Disk_Usage
---- To use on zabbix for LLD
---- Sorted to the greatest size to the lowest size
WITH index_stats AS (
SELECT
pg_class.oid,
nspname AS table_schema,
relname AS index_NAME,
pg_total_relation_size(pg_class.oid) AS total_bytes
You can’t perform that action at this time.