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
--Cria uma tabela de Plano de Contas | |
CREATE TABLE PlanoContas ( | |
ID INT NOT NULL, | |
IDSup INT NULL, | |
Descricao character varying(50) | |
); | |
--Adiciona as constraints | |
ALTER TABLE PlanoContas ADD CONSTRAINT PK_Plano PRIMARY KEY (ID); |
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
<?php | |
/** | |
* Class Metronome | |
* | |
* @see Based on original Java code located at http://rosettacode.org/wiki/Metronome#Java | |
* | |
* @author Heverton Coneglian <[email protected]> | |
*/ | |
class Metronome |
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 |
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
$('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
//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
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
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
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
version: "2" | |
services: | |
database: | |
image: mysql:5.5 | |
volumes: | |
- db_data:/var/lib/mysql | |
restart: always | |
ports: | |
- 3306:3306 |