Skip to content

Instantly share code, notes, and snippets.

@aaoliveira
aaoliveira / mussum-ipsum.sublime-snippet
Created October 2, 2012 18:59 — forked from zenorocha/mussum-ipsum.sublime-snippet
Mussum Ipsum - Snippet para Sublime Text
<!-- Fonte: mussumipsum.com -->
<snippet>
<content><![CDATA[
Mussum ipsum cacilds, vidis litro abertis. Consetis adipiscings elitis. Pra lá , depois divoltis porris, paradis. Paisis, filhis, espiritis santis. Mé faiz elementum girarzis, nisi eros vermeio, in elementis mé pra quem é amistosis quis leo. Manduma pindureta quium dia nois paga. Sapien in monti palavris qui num significa nadis i pareci latim. Interessantiss quisso pudia ce receita de bolis, mais bolis eu num gostis.
Suco de cevadiss, é um leite divinis, qui tem lupuliz, matis, aguis e fermentis. Interagi no mé, cursus quis, vehicula ac nisi. Aenean vel dui dui. Nullam leo erat, aliquet quis tempus a, posuere ut mi. Ut scelerisque neque et turpis posuere pulvinar pellentesque nibh ullamcorper. Pharetra in mattis molestie, volutpat elementum justo. Aenean ut ante turpis. Pellentesque laoreet mé vel lectus scelerisque interdum cursus velit auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac mauris lectus, non scelerisque augu
@aaoliveira
aaoliveira / mailer.php
Created October 3, 2012 11:47 — forked from tcelestino/mailer.php
Using PHPMailer to attachment WordPress files
<?php
define('WP_USE_THEMES', false);
require('../../../wp-load.php');
require_once("class.phpmailer.php");
if(isset($_POST)) {
$nome = $_POST["name"];

Here's how to install PostgreSQL and have it run automatically at startup, on an Ubuntu 10.04 virtual machine using Vagrant. This took me a while to figure out:

Add the default lucid32 base box to your vagrant, if you haven't already:

host> vagrant box add lucid32 http://files.vagrantup.com/lucid32.box 

Now make a new lucid32 virtual machine and install postgresql on it:

@aaoliveira
aaoliveira / cidade-estado.php
Created December 3, 2013 18:14 — forked from emersonsoares/gist:2051743
Lista cidade estado cakephp
<?php
//Primeiramente o controller usuarios, que é onde vou utilizar os selects de cidades e estados
class UsuariosController extends AppController {
public function cadastro() {
$this->set('estados', $this->Estado->find('list'));
}
}
//No controller CidadesController:
<?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 {
@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;
# 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
<?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){
<?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
*/
#!/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