Skip to content

Instantly share code, notes, and snippets.

@tonysm
tonysm / UsuariosController.php
Last active December 14, 2015 01:19
Listando todos os registros utilizando o paginator do CakePHP
<?php
App::uses('AppController', 'Controller');
class UsuariosController extends AppController {
public $paginate = array(
'limit' => 25
);
public function index() {
@tonysm
tonysm / Post.php
Created March 6, 2013 17:12
blog tutorial
<?php
/**
*
*/
class Post extends AppModel
{
public $validate = array(
'title' => array(
'rule' => 'notEmpty'
@tonysm
tonysm / example.php
Last active December 16, 2015 12:28
<?php
// find no model Banco com relacionamento
array(
array(
'Banco' => array(
'nome' => 'teste',
'id' => 1
),
'PlanosDeConta' => array(
@tonysm
tonysm / User.php
Last active December 17, 2015 10:39
concatenating fields between two Models in a belongsTo association. Cakephp
<?php
App::uses('AppModel', 'Model');
/**
* User Model
*
* @property Company $Company
*/
class User extends AppModel {
/**
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@tonysm
tonysm / .vimrc
Created March 1, 2014 18:33
.vimrc
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#rc()
" let Vundle manage Vundle, required
Bundle "gmarik/Vundle.vim"
Bundle "scrooloose/nerdtree"
@tonysm
tonysm / MainJavaCollectionsExcercise.java
Last active August 29, 2015 14:05
JavaCollections - exemplo
import java.util.ArrayList;
import java.util.Collection;
public class Main {
public static void main(String[] args) {
Collection<String> nomes = new ArrayList<String>();
nomes.add("Primeiro nome digitado");
nomes.add("Segundo nome");
@tonysm
tonysm / .bashrc
Last active August 29, 2015 14:05
Talk GAE e PHP
# ...
# put the google sdk on your path
export GAE_PATH="/home/your-username/Programs/google_appengine"
# add the GAE_PATH to your current $PATH
export PATH=$PATH:$GAE_PATH
# to run the local environment
# $ dev_appserver.py --php_executable_path=/usr/bin/php5-cgi ./
@tonysm
tonysm / WithRepository.php
Last active August 29, 2015 14:06
RepositoryPattern
<?php
interface GroupRepository
{
public function createNewGroup($name, $type, User $user);
}
class EloquentGroupRepository implements GroupRepository
{
public function createNewGroup($name, $type, User $user)
@tonysm
tonysm / TasksController.php
Last active August 29, 2015 14:07
Controllers e mecanismos de transporte
<?php
use Acme\Repositories\TaskRepository;
use Acme\Repositories\UserRepository;
use Acme\Mailers\UserMailer;
class TasksController extends Controller
{
/**
* @var Acme\Repositories\TaskRepository