Skip to content

Instantly share code, notes, and snippets.

View robertopc's full-sized avatar

Roberto Pereira da Costa robertopc

View GitHub Profile
@robertopc
robertopc / shell-commands.sh
Last active December 8, 2016 18:07
Linux Shell Commands CheatSheet
# Permissão 644 em lote para arquivos
find DIRETORIO -type f -exec chmod 644 {} \;
# Permissão 755 em lote para pastas
find DIRETORIO -type d -exec chmod 755 {} \;
# Recupera pasta encriptada
sudo ecryptfs-recover-private
# Adicionar usuário ao grupo
@robertopc
robertopc / debug_functions.php
Last active February 19, 2016 17:08
print_r_pre, var_dump_pre, print_r_console, var_dump_console
<?php
/*
* Date: 17/03/2014
* Author : RobertoPC
* Author URI : http://www.robertopc.com.br
* Gist URI : https://gist.github.com/robertopc/43bcf4d28a32bc95956f
* Description: Functions to debug code in PHP
* Functions : print_r_pre, var_dump_pre, print_r_console, var_dump_console
* Version : 1.0
* License : MIT
@robertopc
robertopc / utf8_transliteration.php
Last active August 29, 2015 14:27 — forked from funkjedi/gist:4138022
Converte caracteres especiais em caracteres simples(ASCII). Exemplo: ç > c, á > a, Á > A, etc...
<?php
/*
Converte caracteres especiais em caracteres simples(ASCII).
Exemplos: ç > c, á > a, Á > A, etc...
*/
function utf8_translit($string) {
$characters = array(
" " /* 00a0 'NO-BREAK SPACE' */ => " ",
"¡" /* 00a1 'INVERTED EXCLAMATION MARK' */ => "!",
"¢" /* 00a2 'CENT SIGN' */ => "c",
@robertopc
robertopc / gmail_codeigniter.php
Last active August 29, 2015 14:27
Envio de email com Gmail no CodeIgniter
<?php
$this->load->library('email');
$this->email->initialize(array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_timeout' => '60',
'smtp_user' => '{{{email gmail}}}',
@robertopc
robertopc / Bcrypt.php
Last active August 29, 2015 14:27 — forked from TiuTalk/Bcrypt.php
<?php
/**
* Bcrypt hashing class
*
* @author Thiago Belem <contato@thiagobelem.net>
* @link https://gist.github.com/3438461
*/
class Bcrypt {
<?php
// Encriptando a senha
$senha = 'ola mundo';
$hash = Bcrypt::hash($senha);
// $hash = $2a$08$MTgxNjQxOTEzMTUwMzY2OOc15r9yENLiaQqel/8A82XLdj.OwIHQm
// Salve $hash no banco de dados
// Verificando a senha
$senha = 'ola mundo';
<?php
// Inclui o arquivo class.phpmailer.php localizado na pasta phpmailer
require_once("phpmailer/class.phpmailer.php");
// Inicia a classe PHPMailer
$mail = new PHPMailer();
// Define os dados do servidor e tipo de conexão
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$mail->IsSMTP(); // Define que a mensagem será SMTP
@robertopc
robertopc / bootstrap-elementary.sh
Last active November 26, 2016 13:25
Bootstrap Elementary Linux
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886 &&
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list &&
sudo add-apt-repository -y ppa:noobslab/indicators &&
sudo add-apt-repository -y ppa:noobslab/apps &&
sudo add-apt-repository -y ppa:nilarimogard/webupd8 &&
sudo add-apt-repository -y ppa:mpstark/elementary-tweaks-daily &&
sudo add-apt-repository -y ppa:webupd8team/java &&
sudo add-apt-repository -y ppa:transmissionbt/ppa &&
sudo apt-add-repository -y ppa:umang/indicator-stickynotes &&
sudo add-apt-repository -y ppa:yannubuntu/boot-repair &&
@robertopc
robertopc / gist:e231866361fae2148934
Last active August 9, 2018 01:28 — forked from guisehn/gist:3276015
Validar CPF (PHP)
<?php
function validar_cpf($cpf)
{
$cpf = preg_replace('/\D/', '', (string) $cpf);
// Valida tamanho
if (strlen($cpf) != 11)
return false;
@robertopc
robertopc / regex-validations.js
Last active August 9, 2018 01:27
Validações em Expressões Regulares no Javascript regex js
// Data e hora dd/mm/yyyy hh:mm
var data = "01/01/2000 12:00:00".match(/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/[0-9]{4} (0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/);
console.log(data);
// Email
var email = "email@abc.com".match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
console.log(email);