Skip to content

Instantly share code, notes, and snippets.

View ogabrielsantos's full-sized avatar

Gabriel Santos ogabrielsantos

  • QuintoAndar
  • Brasil
View GitHub Profile
@ogabrielsantos
ogabrielsantos / cake_post_redirec_get.php
Created October 12, 2014 08:45
POST/REDIRECT/GET para uso no CakePHP
<?php
// POST
if ($this->request->is('post') || $this->request->is('put')) {
$uniqId = uniqid();
$this->Session->write('Search.' . $uniqId, json_encode($this->request->data));
// REDIRECT
return $this->redirect('index/search:' . $uniqId);
// GET
@ogabrielsantos
ogabrielsantos / search_cep.php
Last active January 14, 2017 03:27
Buscar CEP diretamente no Correios
<?php
function getAddressDetails($cep)
{
$data = [
'cepEntrada' => $cep,
'tipoCep' => '',
'cepTemp' => '',
'metodo' => 'buscarCep'
];
$requestOptions = [
<?php
interface DataManagement
{
}
class Curl implements DataManagement
{
private $configs;
// Model Gender
public function getList()
{
return [
'M' => 'Masculino',
'F' => 'Feminino'
];
)
// Controller
SELECT CONVERT(CONVERT(COLUNA_ERRADA USING BINARY) USING latin1) AS latin1,
CONVERT(CONVERT(COLUNA_ERRADA USING BINARY) USING utf8) AS utf8
FROM NOME_DA_TABELA
WHERE CONVERT(COLUNA_ERRADA USING BINARY) RLIKE CONCAT('[', UNHEX('80'), '-', UNHEX('FF'), ']')
<?php
// PHP 5.4+
class GenericController
{
public $limit = 99999;
public final function paginate(
$object = null,
array $scope = [],
<?php
// Controller
public function add_cart($id = null)
{
$product = $this->Product->find(
'first',
array(
'recursive' => -1,
'fields' => array(
'Product.id',
<?php
class App
{
public $controllerTitle = null;
public function beforeFilter()
{
if ($this->controllerTitle) {
$this->set('controllerTitle', $this->controllerTitle);
}
<?php
/**
* Class AdController
*/
class AdController extends Controller
{
/**
* @var array
*/
@ogabrielsantos
ogabrielsantos / classes.md
Created April 12, 2016 04:30 — forked from reinink/classes.md
How do you typically organize your classes?

By type

  • /Controllers
  • /Events
  • /Models

By topic

  • /Comments
  • /Posts