This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('132', 'Afeganistão', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('7560', 'África do Sul', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('153', 'Aland, Ilhas', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('175', 'Albânia, República da', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('230', 'Alemanha', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('370', 'Andorra', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('400', 'Angola', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('418', 'Anguilla', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, nome, status, created, modified) VALUES('420', 'Antártica', TRUE, NOW(), NOW()); | |
INSERT INTO paises (codigo, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#/scripts/cloudflare-update-ip-ranges.sh | |
# Taken from https://marekbosman.com/site/automatic-update-of-cloudflare-ip-addresses-in-nginx/ | |
# Location of the nginx config file that contains the CloudFlare IP addresses. | |
CF_NGINX_CONFIG_FILE="/etc/nginx/cloudflare" | |
LOG_FILE="/var/log/messages" | |
# The URLs with the actual IP addresses used by CloudFlare. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2" | |
services: | |
database: | |
image: mysql:5.5 | |
volumes: | |
- db_data:/var/lib/mysql | |
restart: always | |
ports: | |
- 3306:3306 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function ibge_dv(codigo char(6)) | |
returns char(1) as $$ | |
select ((10 - resto) * (resto != 0)::int)::char(1) | |
from ( | |
select | |
( | |
a135 + | |
left(a2, 1)::int + right(a2, 1)::int + | |
left(a4, 1)::int + right(a4, 1)::int + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE estados ( | |
id serial NOT NULL, | |
nome character varying(255) NOT NULL, | |
sigla character(2) NOT NULL, | |
populacao integer NOT NULL, | |
ibge character(2) NOT NULL, | |
CONSTRAINT estados_pkey PRIMARY KEY (id) | |
); | |
INSERT INTO estados (id, nome, sigla, populacao, ibge) VALUES (1, 'Acre', 'AC', 829619, '12'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -n -m 1 SEARCH_TERM FILE_PATH | sed 's/\([0-9]*\).*/\1/' | |
sed -n 16224,16482p filename > newfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//sql | |
create or replace function naturalsort(text) | |
returns bytea language sql immutable strict as | |
$f$ select string_agg(convert_to(coalesce(r[2],length(length(r[1])::text) || length(r[1])::text || r[1]),'SQL_ASCII'),'\x00') | |
from regexp_matches($1, '0*([0-9]+)|([^0-9]+)', 'g') r; $f$; | |
//author: github.com/RhodiumToad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('button[type="submit"]').click(function () { | |
$('input:invalid').each(function () { | |
// Find the tab-pane that this element is inside, and get the id | |
var closest = $(this).closest('.tab-pane'); | |
var id = closest.attr('id'); | |
// Find the link that corresponds to the pane and have it show | |
$('.nav a[href="#' + id + '"]').tab('show'); | |
// Only want to do it once |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONCAT_WS(' ', 'ALTER TABLE', table_name, 'CHANGE', column_name, 'new_name DATETIME;') | |
FROM information_schema.columns | |
WHERE table_schema = 'database' AND column_name = 'old_name'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION gerar_cpf() | |
RETURNS VARCHAR AS | |
$BODY$ | |
-- ROTINA DE GERAÇÃO DE CPF SEM LOOP | |
-- Retorna string com CPF aletório correto. | |
DECLARE | |
vet_cpf INTEGER [11]; --Recebe o CPF | |
soma INTEGER; -- Soma utilizada para o cálculo do DV | |
rest INTEGER; -- Resto da divisão | |
BEGIN |
NewerOlder