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
--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
create temp table pessoa (tipo char(1), cpf int, cnpj int); | |
alter table pessoa add constraint pessoa_check check ( (tipo = 'f' and cpf is not null) <> (tipo = 'j' and cnpj is not null) and cpf is null <> cnpj is null); | |
insert into pessoa values ('f', 1, null); -- true | |
insert into pessoa values ('f', null, null); -- false | |
insert into pessoa values ('f', null, 1); -- false | |
insert into pessoa values ('j', null, 1); -- true | |
insert into pessoa values ('j', null, null); -- false | |
insert into pessoa values ('j', 1, null); -- false |
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 | |
$game = new Game(); | |
while (true) { | |
$game->cycle(); | |
} | |
class Game | |
{ |
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
import java.awt.*; | |
import java.awt.event.*; | |
import java.util.Random; | |
import javax.swing.*; | |
public class Game2048 extends JPanel { | |
enum State { | |
start, won, running, over | |
} |
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 php | |
<?php | |
/* PHP Slowloris | |
* Adapted from the script found here: http://seclists.org/fulldisclosure/2009/Jun/207 | |
* Contains get based attack (slow headers) and post based attack (long content length) | |
* | |
* Author: Seppe vanden Broucke | |
*/ | |
function usage($argv) |
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 | |
/** | |
* Convert Hex Color to RGB | |
* | |
* @param string $h | |
* @return array | |
*/ | |
function hexrgb(&$h) | |
{ |
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
server { | |
listen 80; | |
server_name localhost; | |
root /usr/share/nginx/html/webroot; | |
index index.php; | |
location / { | |
autoindex on; |
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
nginx: | |
image: nginx | |
ports: | |
- "80:80" | |
links: | |
- phpfpm | |
volumes: | |
- ./public:/usr/share/nginx/html | |
- ./nginx/default:/etc/nginx/conf.d/default.conf |
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 verifica_cnpj(text) | |
RETURNS boolean AS | |
$BODY$ | |
-- se o tamanho for 14 prossiga com o cálculo | |
-- senão retorne falso | |
SELECT CASE WHEN LENGTH($1) = 14 | |
THEN | |
( | |
-- verifica se os dígitos coincidem com os especificados | |
SELECT SUBSTR($1, 13, 1) = CAST(digit1 AS TEXT) AND |