Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
<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]
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
<?php
/**
* @todo CakePHP Permissions Array by Kevin Wentworth (Saco Design, Inc.)
* @todo Handles retrieving all ACL Permissions and storing them in an array.
* @todo Comments and bug reports welcome at kevin at sacode sign dot com
*
* @licensed Licensed under UYOR (Use at Your Own Risk)
* @link http://www.mainelydesign.com/blog/view/getting-all-acl-permissions-in-one-lookup-cakephp-1-3#null
*/
<?PHP
class Minhamodel extends AppModel{
//Primeira opção, caso nunca mude o "alias" da model
public $virtualFields = array(
'data_formatada'=>"DATE_FORMAT(Minhamodel.data,'%d/%m/%Y')",
);
//Alternativa caso mude o "alias" da model, melhor opção
public function __construct($id=false,$table=null,$ds=null){
# when I tried to start postgres, I had an error telling me there were no postgres clusters created
# so I had to create one using the `pg_createcluster` command, like the following
pg_createcluster 9.1 main --start
#after creating the cluster, it will start the server because of `--start`
#so I had to change to postgresql user
sudo su - postgres
#to change it's pasword, doing `psql -d <database_name> -U <username>
psql -d postgres -U postgres
@aaoliveira
aaoliveira / valideCpf.php
Created December 12, 2013 20:46
Validador de cpf
/**
* Metódo para válidar um CPF
* @param String $cpf
* @return boolean
*/
public function validCPF($cpf) {
// determina um valor inicial para o digito $d1 e $d2
// pra manter o respeito ;)
$d1 = 0;
$d2 = 0;
<?php
/**
* Breadcrumbs helper
* Allows to generate and display breadcrumbs with a convenient syntax
*
* It uses a <ul><li> syntax but can be extended and protected method overriden to
* generate the markup adapted to your situation
*
*/
class BreadcrumbsHelper extends AppHelper {