Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 / helpers.sh
Created July 29, 2014 19:12
Shell common commands
# Salvar galeria sem as fotos (somente o código-fonte)
# Remove "empty" files
for i in `find /home/*/public_html/* -type f -name 'empty'`; do rm -f $i; done
# Remove error_logs
for i in `find /home/*/public_html/* -type f -name 'error_log'`; do rm -f $i; done
# Permissions fix
find . -type f -exec chmod 644 {} \;
@lucasff
lucasff / strip_1st_char_wp.sql
Created July 29, 2014 19:13
Strip out first character
UPDATE wp_posts SET post_content = TRIM(LEADING '>' FROM post_content);