Skip to content

Instantly share code, notes, and snippets.

View sebastianwebber's full-sized avatar
🏠
Working from home

Sebastian Webber sebastianwebber

🏠
Working from home
View GitHub Profile
@sebastianwebber
sebastianwebber / lista-ds.sh
Last active September 16, 2018 02:24
Lists datasources usage on JBoss AS 4,5 and 6 or JBoss EAP 5
#!/bin/bash
## lista_ds.sh
## Lists datasources usage on JBoss AS 4,5 and 6 or JBoss EAP 5
### SAMPLE OUTPUT:
### INSTANCIA | PORTA | DS | MaxConnectionsInUseCount | AvailableConnectionCount |
### ---------------------|----------|----------------------|---------------------------|---------------------------|
### jboss-server-1 | 1199 | OracleDS | 8 | 50 |
@sebastianwebber
sebastianwebber / create_imdb.sh
Created January 13, 2016 01:30
Converts IMDB into PostgreSQL database
#!/bin/bash
## This script download the data and clone imdb-to-sql repo on github
## Requirements:
### - Python 2.6+
### - psycopg2 python lib
### - git client
### - wget
@sebastianwebber
sebastianwebber / 0-update-test.sql
Last active May 9, 2018 20:35
update tests - to validate a pRest implementation
-- 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 March 20, 2018 13:52
Compare PostgreSQL LSN in ruby
# 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 / bdr-freebsd.md
Last active September 24, 2017 06:35
Install BDR on FreeBSD

BDR Core (currently a fork from postgres project)

Before start, run:

mkdir -p /opt/resources
cd /opt/resources

Clone the BDR source, using the latest branch:

@sebastianwebber
sebastianwebber / guia.md
Last active May 16, 2017 18:23
Guia pra facilitar da vida de quem lê as suas consultas

Guia pra facilitar da vida de quem lê as suas consultas

Consulta original

SELECT e.ID_USUARIO, u.NOME_COMPLETO USUARIO, e.ID_USUARIO_SOLICITANTE , us.NOME_COMPLETO USUARIO_SOLICITANTE, e.DATA_EMPRESTIMO DATA_EMPRESTIMO, e.DATA_DEVOLUCAO DATA_DEVOLUCAO,
         e.STATUS STATUS, l.TITULO
         FROM emprestimo e
         INNER JOIN usuario u ON e.ID_USUARIO = u.ID
         INNER JOIN usuario us ON e.ID_USUARIO_SOLICITANTE = us.ID
@sebastianwebber
sebastianwebber / apply-tuning.sh
Created November 2, 2016 21:41
a script to apply pgconfig using the api (useful for a ansible role/task)
#!/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') }}"
@sebastianwebber
sebastianwebber / pgagent-next-jobs.sql
Created November 4, 2016 21:26
List PGAgent next jobs
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,
@sebastianwebber
sebastianwebber / teste.txt
Created April 1, 2017 00:28
teste com o search_path
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 March 11, 2017 22:57
Desafio Replicação PostgreSQL
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |vb|
vb.gui = false