Skip to content

Instantly share code, notes, and snippets.

View hevertonfreitas's full-sized avatar

Heverton Coneglian de Freitas hevertonfreitas

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hevertonfreitas on github.
  • I am hevertonfreitas (https://keybase.io/hevertonfreitas) on keybase.
  • I have a public key whose fingerprint is 61CF B9F1 4EC1 E2A9 CFC0 D1DB 98B1 A04C 12CC 41B3

To claim this, I am signing this object:

@hevertonfreitas
hevertonfreitas / autopgsqlbackup
Created September 15, 2016 12:17 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@hevertonfreitas
hevertonfreitas / cpf_cnpj.sql
Created November 14, 2016 19:53
Utilidades CPF/CNPJ
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
nginx:
image: nginx
ports:
- "80:80"
links:
- phpfpm
volumes:
- ./public:/usr/share/nginx/html
- ./nginx/default:/etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html/webroot;
index index.php;
location / {
autoindex on;
<?php
/**
* Convert Hex Color to RGB
*
* @param string $h
* @return array
*/
function hexrgb(&$h)
{
@hevertonfreitas
hevertonfreitas / slowloris.php
Last active February 14, 2017 12:49 — forked from Macuyiko/slowloris.php
PHP based slowloris attack with slow headers or post variants. Adapted from script here: <http://seclists.org/fulldisclosure/2009/Jun/207>
#! /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)
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
}
<?php
$game = new Game();
while (true) {
$game->cycle();
}
class Game
{
@hevertonfreitas
hevertonfreitas / check_pessoa.sql
Created March 29, 2017 18:00
constraint para checar o tipo de uma pessoa
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