Skip to content

Instantly share code, notes, and snippets.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/blog.*
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/blog.*
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) app/webroot/$1 [L]
@aaoliveira
aaoliveira / valor_por_extenso.php
Created June 11, 2015 18:40
Valor monetário por extenso
<?php
function valor_extenso($valor=0, $maiusculas=false)
{
// verifica se tem virgula decimal
if (strpos($valor,",") > 0)
{
// retira o ponto de milhar, se tiver
$valor = str_replace(".","",$valor);
// troca a virgula decimal por ponto decimal
@aaoliveira
aaoliveira / removeAventos.php
Created June 12, 2015 15:51
Remove acentos
function removeAcentos($Msg) {
$a = array (
"/[ÂÀÁÄÃ]/" => "A",
"/[âãàáä]/" => "a",
"/[ÊÈÉË]/" => "E",
"/[êèéë]/" => "e",
"/[ÎÍÌÏ]/" => "I",
"/[îíìï]/" => "i",
"/[ÔÕÒÓÖ]/" => "O",
"/[ôõòóö]/" => "o",
@aaoliveira
aaoliveira / Segment.php
Created March 7, 2016 00:20
Classe seguimentos
<?php
namespace app\Models;
use Illuminate\Database\Eloquent\Model;
/**
* Class Segment.
*/
class Segment extends Model
@aaoliveira
aaoliveira / company.php
Created March 7, 2016 00:52
Controller Company
// Metodo no meu controller
public function store(Request $request)
{
try {
DB::beginTransaction();
$data = $request->input();
$validator = Validator::make($data, [
'razao_social' => 'required',
'nome_fantasia' => 'required',
'telefone_1' => 'required',
@aaoliveira
aaoliveira / Segment.php
Created March 7, 2016 01:10
Model Sement
<?php
namespace app\Models;
use Exception;
use Illuminate\Database\Eloquent\Model;
/**
* Class Segment.
*/
@aaoliveira
aaoliveira / sgments.php
Created March 7, 2016 01:11
Controller atual
public function store(Request $request)
{
try {
DB::beginTransaction();
$data = $request->input();
$validator = Validator::make($data, [
'razao_social' => 'required',
'nome_fantasia' => 'required',
'telefone_1' => 'required',
'cnpj' => 'required',
@aaoliveira
aaoliveira / git_meld_install.sh
Created April 27, 2016 16:49 — forked from MarcosX/git_meld_install.sh
Install Meld as the default git diff tool. Must be executed as sudo
#!/bin/bash
echo "Installing meld..."
apt-get install meld -y -qq
echo "Meld [OK]"
echo "Creating meld custom script..."
rm ~/.config/git_meld_diff.sh
touch ~/.config/git_meld_diff.sh
echo "#!/bin/bash" >> ~/.config/git_meld_diff.sh
@aaoliveira
aaoliveira / auth.php
Created September 13, 2016 23:40 — forked from anonymous/auth.php
Exemplo autenticação http basic
$login = 'hjk3kj3h534h53kj4j345';
$password = '3k45jh3k4j5h3k4j5h34kh5k34';
$url = 'https://apic1.hml.stelo.com.br/';
$encode = base64_encode("$login:$password");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
@aaoliveira
aaoliveira / auth2.php
Created September 14, 2016 00:07
Segundo exemplo de auth
try {
$clientId ='cf8db6fe61bc1efebc6ae4f5ab4af60c';
$clientSecret = 'f538b73a11eac49827f6da678e859fa7';
$auth_token = base64_encode($clientId . ':' . $clientSecret);
$target_url = 'https://apic1.hml.stelo.com.br';
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ':' . $clientSecret);
$headers = array('Authorization=Basic ' . $auth_token);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);