Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Cycle::run('tabledados', 'red', 'blue'); //red
* Cycle::run('tabledados', 'red', 'blue'); //blue
* Cycle::run('tabledados', 'red', 'blue'); //red
* Cycle::run('tabledados', 'red', 'blue'); //blue
*/
class Cycle{
protected $values;
protected $ref;
<?php
/**
* PAGINADOR DE QUALQUER TIPO DE DADOS
* Description: Retorna um html de paginação
*
* Ex: //..codigo que lista sua consulta
$records = $mymodel->find("SELECT * FROM mytable where name LIKE '%Pedro%' LIMIT " . ($resultsPerPag * $_REQUEST['p'] . " , $resultsPerPag");
showtablewithrecords( $records );
$totalsearch = $mymodel->count("SELECT * FROM mytable where name LIKE '%Pedro%'"
function breadcrumb($page, $html){
$page_model_o = new edPages();
$html = ' > <a href="?pt='.$page[$page_model_o->F_TITLEURL].'">' . $page[$page_model_o->F_TITLE.$this->getlang()] . "</a>" . $html;
if($aRecord = $page_model_o->getParentPage($page)){
$html = $this->breadcrumb($aRecord , $html);
}
return $html;
}
<?
function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\s\S]*?--[ \t\n\r]*>@' // Strip multi-line comments
);
class ApplicationController < ActionController::Base
layout :current_layout
protected
def current_layout
logged_in? ? 'layout_do_usuario_logado' : 'layout_do_usuario_comum'
emd

Rails 2.3.5 on App Engine (DataMapper)

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working. Rails 2.3.5 currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TinyDS version also: gist.github.com/269075

Install the Development Environment

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine
@stvkoch
stvkoch / Acl.php
Created April 27, 2010 17:39 — forked from jscherer26/Acl.php
<?php
class Model_Acl extends Zend_Acl {
public function __construct() {
// define Roles
$this->addRole(new Zend_Acl_Role('guest')); // not authenicated
$this->addRole(new Zend_Acl_Role('member'), 'guest'); // authenticated as member inherit guest privilages
$this->addRole(new Zend_Acl_Role('admin'), 'member'); // authenticated as admin inherit member privilages
<?php
/**
* Shows how to highlight several words in the body of a html document. It adds spans with specified
* classes around the found words/word parts.
*
* @version $Id: highlightWords.php 444 2010-05-10 09:29:49Z subjective $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert
*/
@stvkoch
stvkoch / mysql-tow orders
Last active September 4, 2015 22:45
tow mysql orders
#Tow mysql orders, more recent first and old lasts!
SELECT IF(dataInitial > NOW(), 0, dataInitial) as dataOrder, dataInitial FROM myTable
ORDER BY dataOrder, dataInitial
#you can created index on the fly!
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.