Skip to content

Instantly share code, notes, and snippets.

View ezimuel's full-sized avatar
🇮🇹
Working remotely, since 2008

Enrico Zimuel ezimuel

🇮🇹
Working remotely, since 2008
View GitHub Profile
@ezimuel
ezimuel / gist:4566485
Created January 18, 2013 17:40
Usage of Zend\Crypt\Password\Apache
use Zend\Crypt\Password\Apache;
$apache = new Apache();
$apache->setFormat('crypt');
printf ("CRYPT output: %s\n", $apache->create('password'));
$apache->setFormat('sha1');
printf ("SHA1 output: %s\n", $apache->create('password'));
@ezimuel
ezimuel / gist:4707734
Created February 4, 2013 16:15
Strange error, PHPUnit is 3.7.13 but the error says PHPUnit 3.5.14
enrico@enrico-desktop:~/Lavoro/Git/zf2/tests$ phpunit Zend\Mvc
PHPUnit 3.7.13 by Sebastian Bergmann.
Cannot open file "ZendMvc.php".
enrico@enrico-desktop:~/Lavoro/Git/zf2/tests$ phpunit ZendTest/Mvc
PHPUNIT: 3.7.13
PHPUnit 3.7.13 by Sebastian Bergmann.
Configuration read from /home/enrico/Lavoro/Git/zf2/tests/phpunit.xml.dist
@ezimuel
ezimuel / gist:4996164
Created February 20, 2013 15:02
Strange composer installation for ZFTool
$ ./composer.phar install
Loading composer repositories with package information
Installing dependencies
- Installing zendframework/zend-version (2.1.1)
Loading from cache
- Installing zendframework/zendframework (2.1.1)
Loading from cache
zendframework/zendframework suggests installing doctrine/common (Doctrine\Common >=2.1 for annotation features)
@ezimuel
ezimuel / gist:5036694
Last active December 14, 2015 05:39
Proposal for Improvement of ZF2 RND
/**
* Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback
*
* @param integer $length
* @param bool $strong true if you need a strong random generator (cryptography)
* @return string
* @throws Exception\RuntimeException
*/
public static function getBytes($length, $strong = false)
{
@ezimuel
ezimuel / gist:5091208
Created March 5, 2013 15:45
class_alias experiment
// rename the Zend\Stdlib\ArrayObject in Zend\Stdlib\ArrayObjectPHPFuture
// and copy he Zend\Stdlib\compatibility\ArrayObject in Zend\Stdlib\ArrayObjectPHPLegacy
if (version_compare(PHP_VERSION, '5.3.4', 'lt') {
class_alias('Zend\Stdlib\ArrayObjectPHPLegacy', 'ArrayObject');
} else {
class_alias('Zend\Stdlib\ArrayObjectPHPFuture', 'ArrayObject');
}
$test = new ArrayObject();
@ezimuel
ezimuel / gist:5135662
Created March 11, 2013 16:55
DB2 configuration file connect using ZF2 and ODBC using config/autoload/local.php
<?php
$database = '';
$hostname = '';
$port = '';
$user = '';
$password = '';
return array(
'db' => array(
@ezimuel
ezimuel / gist:5301941
Created April 3, 2013 14:58
Db2 connect using ODBC parameters
<?php
$database = '';
$user = '';
$password = '';
$hostname = '';
$port = 446;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;".
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
/GET /user
OK Response (200):
{
"user" : {
"name" : "Foo",
"email" : "foo@bar.com"
}
}
@ezimuel
ezimuel / gist:6071979
Created July 24, 2013 16:05
API example calls
RPC: GET /getalbum
Request
{ "id" : 1 }
OK Response (200):
{
"id" : 1,
"artist" : {
"name" : "Metallica",
"history" : "Simply the best heavy metal band ever!",
"genre" : "Heavy metal, Hard rock, Speed metal, Thrash metal"
@ezimuel
ezimuel / gist:6138279
Created August 2, 2013 08:16
ZF2 blog simple schema
CREATE TABLE post (
id int(11) NOT NULL auto_increment,
title varchar(100) NOT NULL,
content TEXT NOT NULL,
user_id int(11),
category_id int(11),
publish_date DATETIME,
PRIMARY KEY (id)
);