Skip to content

Instantly share code, notes, and snippets.

@lucasff
lucasff / html5_hostgator_chat.html
Created July 29, 2014 19:08
Old HostGator USA chat with animated swamp in HTML5. Copyright by HostGator LLC.
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!-- Consider adding an manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en" >
<head>
<meta charset="utf-8">
@lucasff
lucasff / app_controller.php
Created July 15, 2014 22:07
Fix for Pagination
<?php
// carregaMenuSite() antes do $categoria_route
if (in_array('index', $this->params['pass'])) {
unset($this->params['pass'][array_search('index', $this->params['pass'])]);
$this->params['pass'] = array_merge($this->params['pass']);
}
@lucasff
lucasff / .htaccess
Last active June 7, 2020 17:06
CakePHP security optimized .htaccess
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
@lucasff
lucasff / grade_imagem.php
Created July 9, 2014 20:15
afterDelete callback for GradeImagem
<?php
/**
* Remoção dos arquivos das imagens da grade antes de excluir o registro no banco
*
* @param bool $cascade Parâmetro obrigatório do callback do Model
*
* @return bool
*/
public function afterDelete()
{
@lucasff
lucasff / home.ctp
Created July 9, 2014 17:02
Bootstrappified Home Page
<?php
/**
*
*
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Pages
* @since CakePHP(tm) v 0.10.0.1076
*/
if (!Configure::read('debug')):
@lucasff
lucasff / PagSeguroParcelamento.php
Last active July 21, 2023 05:04
PagSeguro Cálculo de Parcelamento por Coeficiente
<?php
/**
* @author Lucas Freitas <lucas@lucasfreitas.com.br
* @license MIT
* @package PagSeguro
* @category eCommerce, Loja Virtual, Pagamentos, PagSeguro
*/
class Pagseguro {
@lucasff
lucasff / pagseguro-post.php
Last active August 29, 2015 14:03
Teste POST PagSeguro
<?php
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
if (count($_POST) > 0 && !isset($_POST['action'])) {
die( "VERIFICADO" );
}
@lucasff
lucasff / mysql-convert-latin1-to-utf8.php
Created July 1, 2014 18:50
MySQL Convert Latin to UTF-8
<?php
/**
* mysql-convert-latin1-to-utf8.php
*
* v1.2
*
* Converts incorrect MySQL latin1 columns to UTF8.
*
* NOTE: Look for 'TODO's for things you may need to configure.
*
@lucasff
lucasff / headers.php
Created July 1, 2014 18:47
PHP Headers
<?php
// See related links for more status codes
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
@lucasff
lucasff / image.php
Created June 30, 2014 21:13
Image Helper for CakePHP 1.3 (and maybe 2.x) to resize and cache images
<?php
class ImageHelper extends Helper
{
var $helpers = array('Html');
var $cacheDir = 'imagecache'; // relative to 'img'.DS
/**
* Automatically resizes an image and returns formatted IMG tag