Skip to content

Instantly share code, notes, and snippets.

View nebiros's full-sized avatar

Juan Alvarez nebiros

View GitHub Profile
@nebiros
nebiros / mb_str_pad.php
Created November 4, 2009 20:30
mb_str_pad
<?php
/**
* mb_str_pad
*
* @param string $input
* @param int $pad_length
* @param string $pad_string
* @param int $pad_type
* @return string
@nebiros
nebiros / IndexController.php
Created November 30, 2009 12:56
Zend_Filter_Input on steroids
<?php
class IndexController extends Zend_Controller_Action {
public function someAction() {
if ( true === $this->getRequest()->isPost() ) {
// Validate form.
$someForm = new App_Filter_Input_SomeForm();
$someForm->setData( $this->getRequest()->getPost() );
if ( false === $someForm->isValid() ) {
#
# How to install php/java bridge on Ubuntu.
#
# aptitude install sun-java6-jre sun-java6-fonts sun-java6-jdk liblucene-java libitext-java \
php5-dev php5-cgi libtcnative-1
# update-java-alternatives -s java-6-sun
# dpkg --force-architecture -i php-java-bridge_5.4.4.2-3_i386.deb
@nebiros
nebiros / index.php
Created January 14, 2010 15:53
How to implement Zend_Paginator without Zend
<?php
defined( "APPLICATION_PATH" )
|| define( "APPLICATION_PATH", realpath( dirname( __FILE__ ) ) );
// Ensure library/ is on include_path.
set_include_path( implode( PATH_SEPARATOR, array(
realpath( APPLICATION_PATH . "/library" ), // Aca va a estar la carpeta Zend que viene con el .tag.gz del ZF
get_include_path(),
) ) );
@nebiros
nebiros / ErrorController.php
Created January 15, 2010 18:40
Display AJAX errors on Zend Framework
<?php
class ErrorController extends Zend_Controller_Action
{
public function errorAction()
{
/** Other suff */
if ( true === $this->getRequest()->isXmlHttpRequest() )
{
@nebiros
nebiros / IndexController.php
Created January 28, 2010 13:13
Export data to excel on Zend Framework
<?php
class IndexController extends Zend_Controller_Action
{
public function exportXlsAction()
{
set_time_limit( 0 );
$model = new Default_Model_SomeModel();
$data = $model->getData();
@nebiros
nebiros / App_Thumb.php
Created February 23, 2010 15:06
Thumbnails lib
<?php
class App_Thumb
{
protected $_width = null;
protected $_oldWidth = null;
protected $_height = null;
protected $_oldHeight = null;
protected $_imagePath = null;
protected $_resource = null;
@nebiros
nebiros / csvn.bat
Created June 13, 2010 19:52
Remove .svn folders on *nix and windoze
FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q %G
@nebiros
nebiros / titanium_hold_menu.js
Created September 12, 2010 20:42
Titanium hold menu
var holdTime = 2000, timeout;
productView.addEventListener( "touchstart", function ( e ) {
timeout = setTimeout( function( e ) {
// you function here. e.source is you tableViewRow.
var dialog = Titanium.UI.createOptionDialog( {
options: ["Notificar precio"],
destructive: 2,
cancel: 1,
title: "Opciones"
@nebiros
nebiros / Cache.php
Created September 23, 2010 16:20
App_Cache
<?php
/**
* Based on FileCache class by Erik Giberti,
* http://af-design.com/blog/2010/07/30/simple-file-based-caching-in-php/
*
* @author nebiros
*/
class App_Cache {
/**