Skip to content

Instantly share code, notes, and snippets.

@renerdias
renerdias / media-query.css
Created December 9, 2018 16:38 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@renerdias
renerdias / backup_pg.sh
Created April 7, 2019 15:29 — forked from sjlombardo/backup_pg.sh
PostgreSQL Daily Continuous Backup Script
#!/bin/bash
backup_dir=/backup/pg_backups
wal_dir=/backup/postgresql
today=$(date +%Y-%m-%d.%H:%M:%S)
yesterday=$(find $backup_dir -maxdepth 1 -type d -name "*" -exec basename {} \; | tail -n +2 | grep -v "lost+found" | sort -rn | head -1)
psql -c "select pg_start_backup('$today', true);"
if [ $? = 0 ]
@renerdias
renerdias / tg_auditoria.sql
Last active April 19, 2019 23:43 — forked from wyanez/tg_auditoria.sql
[pgsql] Modelo de Trigger de Auditoria en PostgreSQL
DECLARE
inst TEXT;
old_v TEXT;
new_v TEXT;
alterado_v BOOLEAN;
metadata_record RECORD;
BEGIN
RAISE NOTICE '(%) -> % [%,%,%]',TG_OP, TG_TABLE_NAME,current_user,current_time,current_date;
alterado_v = FALSE;
raise notice '1°: %', alterado_v;
@renerdias
renerdias / gist:c389f0d630bb1a73e3c5992d3aff3c6d
Created April 23, 2019 13:52 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
create or replace function auditoria.trig_func_auditoria() returns trigger as
$body$
declare
nNomeTabela name;
nNomeTabelaAuditoria name;
tIdAuditoria auditoria.ta_padrao.id_auditoria%type;
tDataAuditoria auditoria.ta_padrao.dt_auditoria%type;
tOpAuditoria auditoria.ta_padrao.op_auditoria%type;
tpid auditoria.ta_padrao.pid%type;
tApplicationName auditoria.ta_padrao.application_name%type;
@renerdias
renerdias / func_criar_tabela_auditoria.sql
Created April 23, 2019 21:32
Cria uma tabela de log para cada tabela no schema public
create or replace function auditoria.func_criar_tabela_auditoria(nNomeTabela name, bRecriar boolean) returns boolean as
$body$
declare
nNomeTabelaAuditoria name;
begin
-- overlay substitui o tb no nome da tabela por ta
nNomeTabelaAuditoria := 'auditoria.' || overlay(nNomeTabela placing 'ta' from 1 for 2);
if bRecriar then
execute 'drop table if exists ' || nNomeTabelaAuditoria;
@renerdias
renerdias / func_auxiliar.sql
Created April 23, 2019 21:34
Funções auxiliares para auditoria
create or replace function auditoria.func_application_name(iprocpid int) returns text as
$body$
declare
tApplicationName text;
begin
select
application_name into tApplicationName
from
pg_stat_activity
where
@renerdias
renerdias / auditoria_inicio.sql
Created April 23, 2019 21:35
Cria o schema de auditoria e uma tabela com dados comuns de auditoria
create schema auditoria;
create table auditoria.ta_padrao (
id_auditoria bigint not null,
dt_auditoria timestamp not null,
op_auditoria char(1) not null,
pid int not null,
application_name text not null,
client_hostname text not null
);
@renerdias
renerdias / auditoria_fim.sql
Created April 23, 2019 21:36
Cria tabela de auditoria para todas as tabelas em public
select
tablename,
auditoria.func_criar_tabela_auditoria(tablename, false)
from
pg_tables
where
schemaname = 'public'
order by
tablena
-- Create a mySQL table to hold hashed passwords and random salt
--
-- SQL create script for for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`user_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(30) NOT NULL,
`reg_date` date NOT NULL,