Skip to content

Instantly share code, notes, and snippets.

Sebastian Webber sebastianwebber

Block or report user

Report or block sebastianwebber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@sebastianwebber
sebastianwebber / top-tables-pgsql-lld.sql
Last active Nov 10, 2016
Lista as tabelas para ser usada no lld do zabbix
View top-tables-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 table_stats AS (
SELECT
pg_class.oid,
nspname AS table_schema,
relname AS TABLE_NAME,
pg_class.reltuples AS row_estimate,
View pgagent-next-jobs.sql
SELECT
pga_job.jobname as job_name,
pga_jobstep.jstdbname as database_name,
pgagent.pga_next_schedule(
pga_schedule.jscid,
pga_schedule.jscstart,
pga_schedule.jscend,
pga_schedule.jscminutes,
pga_schedule.jschours,
pga_schedule.jscweekdays,
View oracle-db-size.sql
-- Found on: http://techxploration.blogspot.com.br/2012/06/script-to-get-oracle-database-size.html
SET SERVEROUTPUT ON
Declare
ddf Number:= 0;
dtf Number:= 0;
log_bytes Number:= 0;
total Number:= 0;
@sebastianwebber
sebastianwebber / apply-tuning.sh
Created Nov 2, 2016
a script to apply pgconfig using the api (useful for a ansible role/task)
View apply-tuning.sh
#!/bin/bash
PGCONFIG_URL="https://api.pgconfig.org/v1/tuning/get-config"
DEFAULT_FORMAT="alter_system"
ENVIRONMENT="{{ postgresql_default_profile }}"
PG_VERSION="{{ postgresql_version }}"
TOTAL_RAM=$(({{ ansible_memtotal_mb }} /1024))
ADMIN_USER="postgres"
USE_RESTORE_TUNING="{{ apply_restore_tuning | default('NO') }}"
You can’t perform that action at this time.