Skip to content

Instantly share code, notes, and snippets.

View jrbasso's full-sized avatar

Juan Basso jrbasso

  • Zumba
  • Pembroke Pines, FL, USA
  • X @jrbasso
View GitHub Profile
<?php
$data = array_fill(0, 1000, 1.0);
$iterations = 10000;
$m = microtime(true);
while ($iterations-- > 0) {
json_encode($data);
}
echo "Elapsed time: ", (microtime(true) - $m), "\n";
<?php
namespace Cake;
class Router {
protected static $_collection;
protected static $_vars;
public static function test() {
static::$_collection = new \stdClass();

Keybase proof

I hereby claim:

  • I am jrbasso on github.
  • I am jrbasso (https://keybase.io/jrbasso) on keybase.
  • I have a public key whose fingerprint is FB6C 0029 F72B 33F3 69CF C90F B81C DD9B B318 78F8

To claim this, I am signing this object:

@jrbasso
jrbasso / gist:730596
Created December 6, 2010 17:19
Usando SOAP
// app/config/databases.php
class DATABASE_CONFIG {
var $default = array(...);
var $soap = array('datasource' => 'Datasources.Soap', ...);
var $test = array(...);
}
// app/models/servico.php
<?php
// Fake methods
function pluginSplit() {}
function env() {}
class ValidateAPI {
protected $_cakePath;
protected $_files = array();
@jrbasso
jrbasso / cake3ns.markdown
Created December 10, 2011 23:39
CakePHP 3.0 Namespace

CakePHP Core

  • Core namespace: Cake
  • Namespace will follow the directories, ie. Cake\Cache\Engine\ApcEngine, Cake\Controller\Controller
  • View files don't need namespaces
  • Basic functions will not be namespaced as well
  • Use the class loader defined by the PHP Standard Group, see https://gist.github.com/562509
  • Suffixes will not be removed (ie. HtmlHelper will be Cake\View\Helper\HtmlHelper instead of Cake\View\Helper\Html)
  • Remove App::uses()
  • Remove filemap
@jrbasso
jrbasso / pre-commit
Created March 31, 2012 21:54
Pre commit hook for CakePHP
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
echo "Checking PHP Lint..."
FILES=""
for FILE in `git diff --cached --name-only --diff-filter=ACMR HEAD | egrep \\\\.\(php\|ctp\)\$`
do
php -l -d display_errors=0 $PROJECT/$FILE
if [ $? != 0 ]
@jrbasso
jrbasso / update_use.php
Created May 27, 2012 03:34
Update "use" to be 1 per class and ordered by name
<?php
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__));
while ($dir->valid()) {
$filename = $dir->key();
if (substr($filename, -4) !== '.php' || strpos($filename, '.git')) {
$dir->next();
continue;
}
@jrbasso
jrbasso / proof_bug.diff
Created June 23, 2012 01:22
PHP_CodeSniffer bug on ScopeIndent
diff --git a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc
index 848fc56..0d0e224 100644
--- a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc
+++ b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.inc
@@ -37,6 +37,16 @@ class Test
}
}
+ function hello4()
+ {
@jrbasso
jrbasso / cakebin.php
Created July 9, 2012 01:03
Example how to create bin in bin.cakephp.org
<?php
namespace Cake\Bin;
class Push {
const DEFAULT_TYPE = 'text';
const CAKEBIN_URL = 'http://bin.cakephp.org';
protected $allowedTypes = array(