Skip to content

Instantly share code, notes, and snippets.

View thiagosf's full-sized avatar
🏠
Always working at home

Thiago Silva Ferreira thiagosf

🏠
Always working at home
View GitHub Profile
@thiagosf
thiagosf / missing_view.ctp
Created November 21, 2010 17:39
Arquivo de erro para facilitar na criação de arquivos de template para CakePHP
<h2><?php __('Missing View'); ?></h2>
<p class="error">
<strong><?php __('Error'); ?>: </strong>
<?php printf(__('The view for %1$s%2$s was not found.', true), '<em>' . $controller . 'Controller::</em>', '<em>' . $action . '()</em>'); ?>
</p>
<p class="error">
<strong><?php __('Error'); ?>: </strong>
<?php printf(__('Confirm you have created the file: %s', true), $file); ?>
</p>
<p class="notice">
@thiagosf
thiagosf / missing_controller.ctp
Created November 21, 2010 17:42
Arquivo de erro para facilitar na criação de arquivos de controle para CakePHP
<h2><?php __('Missing Controller'); ?></h2>
<p class="error">
<strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('%s could not be found.', true), "<em>" . $controller . "</em>");?>
</p>
<p class="error">
<strong><?php __('Error'); ?>: </strong>
<?php echo sprintf(__('Create the class %s below in file: %s', true), "<em>" . $controller . "</em>", APP_DIR . DS . "controllers" . DS . Inflector::underscore($controller) . ".php");?>
</p>
<pre>
@thiagosf
thiagosf / functions.php
Created December 7, 2010 15:58
Helper Functions 1.0
<?php
/**
* Helper com funcoes diversas
*/
class FunctionsHelper extends AppHelper
{
var $helpers = array('Html', 'Form', 'Session');
// Data do perfil: 10 de novembro de 1970
@thiagosf
thiagosf / database.php
Created February 18, 2011 00:09
Classes para facilitar manipulação com banco de dados (versão 2.0).
<?php
/**
* Config do banco
*/
class DATABASE_CONFIG {
public $config = array();
public $dev = array(
'host' => 'localhost',
'login' => 'root',
@thiagosf
thiagosf / Paginator.php
Created May 25, 2011 17:46
Paginação simples em OOP
<?php
/**
* Paginacao de dados
*/
class Paginator
{
/**
* Total de registros para ser paginados
*/
@thiagosf
thiagosf / excel.php
Created May 27, 2011 11:03
Helper para exportar dados para Excel
<?php
class ExcelHelper extends AppHelper
{
var $filename = 'arquive.csv';
var $rows = array();
var $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?\>
<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"
@thiagosf
thiagosf / snippets.conf
Created May 30, 2011 19:09
Snippets para Geany
# Geany's snippets configuration file
#
# use \n or %newline% for a new line (it will be replaced by the used EOL char(s) - LF, CR/LF, CR).
# use \t or %ws% for an indentation step, it will be replaced according to the current document's indent mode.
# use \s to force whitespace at beginning or end of a value ('key= value' won't work, use 'key=\svalue').
# use %key% for all keys defined in the [Special] section.
# use %cursor% to define where the cursor should be placed after completion. You can define multiple
# %cursor% wildcards and use the "Move cursor in snippet" to jump to the next defined cursor
# position in the completed snippet.
# You can define a section for each supported filetype to overwrite default settings, the section
@font-face {
font-family: 'TitilliumMaps';
src: url('../fonts/TitilliumMaps26L002.eot');
src: local('☺'), url('../fonts/TitilliumMaps26L002.woff') format('woff'), url('../fonts/TitilliumMaps26L002.ttf') format('truetype');
}
@thiagosf
thiagosf / get_title.php
Created June 17, 2011 17:16
Pega título de uma URL
function getTitle ($url) {
$fh = fopen($url, "r");
$str = fread($fh, 1500);
fclose($fh);
$str2 = strtolower($str);
$start = strpos($str2, "<title>")+7;
$len = strpos($str2, "</title>") - $start;
return substr($str, $start, $len);
}
@thiagosf
thiagosf / delicious.php
Created June 27, 2011 16:38
Funçoes para resgatar dados do Delicious
<?php
// Mais informações
// http://www.delicious.com/help/feeds
// Count
function delicious_count($url) {
$count = 0;