Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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);
archlinux-keyring
archlinux-wallpaper
ark
atom
bluez
bluez-utils
darktable
dialog
dnsutils
docker
Part 1
1. Read Text File
sed r text.txt
2. Find & Replace
sed ‘s/UNIX/MINIX/g’ text.txt
@douglascabral
douglascabral / change-url-wp.sql
Created September 16, 2016 20:29
Change the URL WordPress
UPDATE wp_commentmeta SET meta_value = REPLACE(meta_value, 'http://site.com.br', 'http://localhost/');
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://site.com.br', 'http://localhost/');
UPDATE wp_posts SET guid = REPLACE(guid, 'http://site.com.br', 'http://localhost/');
@douglascabral
douglascabral / iptables.txt
Created September 16, 2016 15:03
iptables example ping
Allow Ping from Outside to Inside
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
Allow Ping from Inside to Outside
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
@douglascabral
douglascabral / .bashrc
Created September 16, 2016 13:38
Extract command for bash
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract ."
else
if [ -f $1 ] ; then
# NAME=${1%.*}
# mkdir $NAME && cd $NAME
case $1 in
*.tar.bz2) tar xvjf ../$1 ;;
@douglascabral
douglascabral / mysql-import.sh
Created August 19, 2016 20:56
MySQL Import Data
mysql --host=<IP_HOST_HERE> \
--user=<USER> \
--password=<PASSWORD> \
<DATABASE> < /path/file/here.sql
@douglascabral
douglascabral / composer.json
Created August 19, 2016 14:35
Eloquent outside Laravel
{
"require": {
"illuminate/database": "*"
}
}