Skip to content

Instantly share code, notes, and snippets.

View augustohp's full-sized avatar

Augusto Pascutti augustohp

View GitHub Profile
@augustohp
augustohp / SplClassLoader.php
Created October 16, 2010 07:22 — forked from jwage/SplClassLoader.php
Little mod for not breaking class_exists() usage with non-existing classes, preventing a Fatal Error
<?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.
@augustohp
augustohp / svn2git.sh
Created June 13, 2011 22:33
SVN to GIT migration shell script
#!/bin/sh
# Migrates a SVN repository to a git repository.
#
# Author: Augusto Pascutti <augusto@phpsp.org.br>
COMMAND=$0;
SVN=`which svn 2> /dev/null`;
GIT=`which git 2> /dev/null`;
READER="";
RETURN="";
@augustohp
augustohp / brew_highlight
Created July 9, 2011 04:57
Brew Error: brew install -v highlight
==> Downloading http://www.andre-simon.de/zip/highlight-3.5.tar.bz2
File already downloaded in /Users/pascutti/Library/Caches/Homebrew
/usr/bin/tar xf /Users/pascutti/Library/Caches/Homebrew/highlight-3.5.tar.bz2
==> make PREFIX=/usr/local/Cellar/highlight/3.5 conf_dir=/usr/local/etc/highlight
make PREFIX=/usr/local/Cellar/highlight/3.5 conf_dir=/usr/local/etc/highlight
make -C ./src -f ./makefile HL_DATA_DIR=/usr/local/Cellar/highlight/3.5/share/highlight/ HL_CONFIG_DIR=/usr/local/etc/highlight
c++ -Wall -O2 -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -c -I ./include/ -I/usr/include/lua5.1 ./core/stylecolour.cpp
c++ -Wall -O2 -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -c -I ./include/ -I/usr/include/lua5.1 ./core/stringtools.cpp
c++ -Wall -O2 -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -c -I ./include/ -I/usr/include/lua5.1 ./core/xhtmlgenerator.cpp
c++ -Wall -O2 -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -c -I ./include/ -I/usr/include/lua5.1 ./core/latexgenerator.cpp
@augustohp
augustohp / cmd_osx_apc_php53.sh
Created August 7, 2011 23:56
APC installation for OSX
#!/bin/bash
#
# Downloads and install latest APC extension to OSX php (Zend Server).
# Tested under OSX 10.6.7, more feedback is appreciated.
#
# OSX is 64bit but the PHP binary in Zend Server is compiled in 32bit mode only,
# so to have APC working with Zend Server on OSX statically compiling it with default
# recommended flags and forced i386 architecture.
# I suppose that Zend Server's binary path is already into your PATH variable and it
# is used before the native PHP binary bundled with OSX.
@augustohp
augustohp / SingletonPattern.php
Created October 3, 2011 18:23
PHP Singleton implementation example
<?php
class SingletonPattern
{
private static $instance;
private function __construct()
{
}
@augustohp
augustohp / silly.me.php
Created October 24, 2011 08:48
A silly database interaction implementation
<?php
function examples() {
$say = new Sql();
echo $say->what->happens->when->you->think->out->of->the->box->raw('?'),"\n\n";
// Our database
$pdo = new Pdo('sqlite::memory:');
//$pdo = new Pdo('mysql:dbname=test;host=127.0.0.1', 'zend', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@augustohp
augustohp / mapper_uc1.php
Created November 23, 2011 13:01
Data Mapper use case
<?php
$map = array('id'=>'id', 'login'=>'login', 'passwd'=>'passwd');
$origin = array('id'=>1, 'login'=>'foo', 'passwd'=>'bar');
$mapper = new Respect\Data\Mapper($map);
$object = new StdClass;
$mapper->toInstance($origin, $object);
@augustohp
augustohp / gist:1402858
Created November 29, 2011 01:03 — forked from wesleyvicthor/gist:1392133
twig array
{% if cases_list.ProcessInstance is defined %}
{% for case in cases_list.ProcessInstance %}
{% for activity in case.activities.children() %}
<tr>
{% for variable in case.clientVariables.children() %}
{{ set value = variable.xpath('string[2]') }}
<td>{{ array_pop(value) }}</td>
{% endfor %}
<td><a href="{{ cloud_link_address }}{{ activity.uuid.value }}" target="_blank">{{ activity.name }}</a></td>
<td>#</td>
@augustohp
augustohp / example_iterator.php
Created December 28, 2011 18:53
Example iterator
<?php
class Entidade
{
public function toArray()
{
return array('uhull');
}
}
class EntityIterator extends \ArrayIterator
@augustohp
augustohp / Loader.php
Created January 4, 2012 17:57 — forked from caferrari/Loader.php
VorticePHP2 Loader
<?php
/**
* Simple loader class
*
* Usage: new Vortice\Common\Loader('Zend', './Zend');
* @author Carlos André Ferrari <carlos@ferrari.eti.br>
*/
namespace Vortice\Common;