Skip to content

Instantly share code, notes, and snippets.

View jotapepinheiro's full-sized avatar
🏠
Working from home

João Paulo Pinheiro jotapepinheiro

🏠
Working from home
View GitHub Profile
@jotapepinheiro
jotapepinheiro / slugUrl.sql
Created April 10, 2012 04:35
SLUG URL POSTGRE FUNCTION
CREATE OR REPLACE FUNCTION public.url_slug (
s_texto text
)
RETURNS varchar AS
$body$
DECLARE
total integer;
BEGIN
s_texto := replace(s_texto , 'U$', 'dolares');
s_texto := replace(s_texto , 'R$', 'reais');
<?php
function soma_horas() {
$i = $s = $hour = $min = $sec = 0;
foreach (func_get_args() as $time) {
sscanf($time, '%d:%d:%d', $hour, $min, $sec);
$i += ($hour * 60) + $min + ($sec / 60);
$s += $sec;
}
@jotapepinheiro
jotapepinheiro / rocket.chat.txt
Last active December 7, 2017 04:41
Install Rocket.Chat Ubuntu 16.04
## command 1- Instalar pacotes essenciais
apt-get install curl graphicsmagick build-essential
## command 2- Adicionar packages mongodb
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
## command 3- Adicionar repository mongodb
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
## command 4- Atualizar ubuntu e instalar mongodb
@jotapepinheiro
jotapepinheiro / vst-install.sh
Created December 7, 2017 02:11
Install VestaCP on Ubuntu 16.04
#!/bin/bash
# Vesta Ubuntu installer v.05
# Modified by David B (KernelPanic89) to work for Ubuntu
# Revision 1.0 - Sep 06 2016
#----------------------------------------------------------#
# Variables&Functions #
#----------------------------------------------------------#
@h@export PATH=$PATH:/sbin
@jotapepinheiro
jotapepinheiro / dominio.php
Last active June 22, 2017 03:45
Verifica Domínio Disponivel
<?php
function geraLetras($length) {
global $abc;
settype($abc, "string");
$abc = "abcdefghijklmnopqrstuvwxyz";
settype($length, "integer");
@jotapepinheiro
jotapepinheiro / wp-remoto.php
Created October 29, 2016 06:34
Get Remote Data Wordpress
<?php
header("Content-type: application/json; charset=utf-8");
$http_origin = $_SERVER['HTTP_ORIGIN'];
$allowed_http_origins = array(
"http://site1.com.br",
"http://site2.com.br",
"http://site3.com.br"
);
if (in_array($http_origin, $allowed_http_origins)){
@jotapepinheiro
jotapepinheiro / index.php
Created August 28, 2016 23:51
Validações PHP
<?php
include("Validator.php");
$email = "asasasas@outlook.com";
if(Validator::EmailReal($email)){
echo "The email is valid";
}else{
echo "That’s an invalid email";
@jotapepinheiro
jotapepinheiro / moeda.php
Created August 28, 2016 23:59
Formata Moeda PHP
<?php
$preco=Convert('USD', 'BRL','1,00');
if($preco!=false){
echo $preco;
}
else{echo "conversão não possível";}
function Convert($from, $to, $preco)
{
$url = "http://www.google.com/finance/converter?a=$preco&from=$from&to=$to";
@jotapepinheiro
jotapepinheiro / mask.php
Created August 28, 2016 23:58
Mascaras PHP
<?php
function mask($val, $mask)
{
$maskared = '';
$k = 0;
for($i = 0; $i<=strlen($mask)-1; $i++)
{
if($mask[$i] == '#')
{
if(isset($val[$k]))
server {
listen 80;
server_name laravel.dev;
root /var/www/vhosts/laravel.dev/public;
index index.html index.htm index.php;
charset utf-8;
location / {