Skip to content

Instantly share code, notes, and snippets.

View sidymar's full-sized avatar

Sidymar sidymar

View GitHub Profile
@sidymar
sidymar / delay_pg_restore_matviews
Created July 28, 2021 14:24 — forked from kmatt/delay_pg_restore_matviews
Delay materialized view refresh during pg_restore
pg_dump database -Fc backup.dump
pg_restore -l backup.dump | sed '/MATERIALIZED VIEW DATA/d' > restore.lst
pg_restore -L restore.lst -d database backup.dump
pg_restore -l backup.dump | grep 'MATERIALIZED VIEW DATA' > refresh.lst
pg_restore -L refresh.lst -d database backup.dump
@sidymar
sidymar / bulk-upsert-from-temporary-table.sql
Created August 5, 2020 18:51 — forked from seanbehan/bulk-upsert-from-temporary-table.sql
Perform an "upsert" from CSV file using Postgres copy command #sql #psql
create temporary table temp (symbol varchar(255), open decimal, high decimal, low decimal, close decimal, volume varchar(255), date date );
create table if not exists stocks (id serial primary key, symbol varchar(255), open decimal, high decimal, low decimal, close decimal, volume varchar(255), date date, created_at timestamp, updated_at timestamp);
copy temp (symbol, date, open, high, low, close, volume) from '/path/to/file.csv' with delimiter ',' csv header;
delete from stocks using temp where stocks.date = temp.date and stocks.symbol = temp.symbol;
insert into stocks (symbol, open, high, low, close, volume, date) select symbol, open, high, low, close, volume, date from temp;
@sidymar
sidymar / feriados.sql
Created April 14, 2020 15:33 — forked from dekassegui/feriados.sql
Script para criação de tabelas de feriados nacionais móveis e fixos, com cáculo automático das datas.
/**
* Parte do Projeto LUX, em desenvolvimento desde 12 de novembro de 2016.
*
* Contém implementação do "Cálculo da Páscoa" pelo método tabular para
* datas no calendário Gregoriano, descrito em "Computus":
*
* https://en.wikipedia.org/wiki/Computus#Gregorian_calendar
*
* com adequações para o SQLite 3.7.13 ou mais recente, privilegiando o
* uso de datas no padrão ISO-8601.
@sidymar
sidymar / rabbitmq_conf_homebrew
Created January 6, 2020 11:58 — forked from robcowie/rabbitmq_conf_homebrew
Location of rabbitmq config files with homebrew
Rabbitmq conf locations for homebrew
/usr/local/etc/rabbitmq/rabbitmq-env.conf
/usr/local/etc/rabbitmq/rabbitmq