This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function nicetime($date){ | |
if(empty($date)) { | |
return "No date provided"; | |
} | |
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade"); | |
$lengths = array("60","60","24","7","4.35","12","10"); | |
$now = time(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$conditions = array( | |
'conditions' => array('codigo' => '24150'), | |
'contain' => array( | |
'Card'=>array( | |
'Partner' => array ( | |
'Contact' => array( | |
'conditions' => array('Contact.coords_lat' => '38.710930') | |
) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//ref: http://cubiq.org/the-perfect-php-clean-url-generator | |
setlocale(LC_ALL, 'en_US.UTF8'); | |
function toAscii($str, $replace=array(), $delimiter='-') { | |
if( !empty($replace) ) { | |
$str = str_replace((array)$replace, ' ', $str); | |
} | |
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$count = $model->countAll(); | |
$pages = new Paginator; | |
$pages->items_total = $count; | |
$pages->mid_range = 9; | |
$pages->paginate(); | |
$options['limit'] = $pages->low.', '.($pages->high + 1); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$str = 'This is an image: google.ca/images/srpr/logo3w.png<br> | |
YouTube: http://www.youtube.com/watch?v=V2b8ilapFrI&feature=related <br> | |
Stackoverflow: http://stackoverflow.com/'; | |
function converterLinksEmVideos($arr){ | |
if(strpos($arr[0], 'http://') !== 0){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//gerado pelo http://themergency.com/generators/cpt-code-output/?id=8966 | |
add_action( 'init', 'register_cpt_atividade' ); | |
function register_cpt_atividade() { | |
$labels = array( | |
'name' => _x( 'Atividades', 'atividade' ), | |
'singular_name' => _x( 'Atividade', 'atividade' ), | |
'add_new' => _x( 'Adicionar Atividade', 'atividade' ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PHP error handling for production servers | |
# disable display of startup errors | |
php_flag display_startup_errors off | |
# disable display of all other errors | |
php_flag display_errors off | |
# disable html markup of errors | |
php_flag html_errors off |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.extend({ //plugins without context. e.g: $.plugin(); | |
firebugLite: function () { | |
var vars = { | |
keys: [], | |
sequence: "68,69,66,85,71", | |
loaded: false, | |
serviceURL: 'https://getfirebug.com/firebug-lite.js' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Vantagens: | |
- Organizador de métodos e propriedades, permite ser estendido por outros arquivos js. | |
- Utilizar um 'namespace' favorece o melhor consumo de memória (nos antigos IE). | |
Desvantagens: | |
- Como não é uma classe e em runtine eu não crio uma instância (new NAP()), | |
não é possível usar o this dentro de um método do objeto NAP | |
para invocar outro que também é método do objeto NAP. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Inspirado no post: http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth | |
Vantagens: | |
- Permitir a utilização de métodos/propriedades privadas. | |
- Adicionar metodos ou propriedades ao objeto ProjetoX a partir de outros arquivos js | |
Desvantagens: | |
- Como não é uma classe e em runtine eu não crio uma instância (new NAP()), | |
não é possível usar o this dentro de um método do objeto NAP | |
para invocar outro que também é método do objeto NAP. |