Skip to content

Instantly share code, notes, and snippets.

@douglascabral
douglascabral / avoid-f5.js
Created October 27, 2016 14:13
Avoid the F5 in webpage
// @see http://jsfiddle.net/SpYk3/C85Hs/
function disableF5(e) { if ((e.which || e.keyCode) == 116) e.preventDefault(); };
document.addEventListener('keydown', disableF5);
@douglascabral
douglascabral / echo-date-cert-ssl.sh
Created November 18, 2016 14:22
Show date SSL Certificate
echo | openssl s_client -connect douglascabral.com.br:443 2>/dev/null | openssl x509 -noout -dates
@douglascabral
douglascabral / curl-get.php
Last active March 30, 2017 22:20
CURL PHP Example
<?php
$api = 'http://alguma-api-aqui.com.br';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('chave: valor'));
@douglascabral
douglascabral / guid.rgx
Created December 1, 2016 14:20
REGEX para validar GUIDs
/([0-9A-Fa-f]{8})-([0-9A-Fa-f]{4}-){3}([0-9A-Fa-f]{12})/
@douglascabral
douglascabral / kong
Last active July 30, 2018 20:20
Kong init.d
#!/bin/sh
#
# chkconfig: - 80 45
# description: Starts and stops Kong
# Enable: http://manpages.ubuntu.com/manpages/zesty/man8/update-rc.d.8.html
# update deamon path to point to the kong executable
start() {
echo -n "Starting Kong... "
kong start
if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) {
//is IE 11 or below
}
SELECT JSON_EXTRACT(nome_do_campo_com_json, "$.nome_da_chave") FROM tbl
@douglascabral
douglascabral / remove-querystring.php
Created June 12, 2017 15:00
Remove querystring from url
$url = preg_replace('/\?.*/', '', $url);
@douglascabral
douglascabral / log-mysql.sql
Created July 31, 2017 13:37
Enable/disable mysql log
SET global general_log = 0; //Disable
SET global general_log = 1; //Enable
@douglascabral
douglascabral / delete-files.sh
Created August 24, 2017 18:01
Delete matching files with pattern
find . -name \README.txt -type f -delete