Skip to content

Instantly share code, notes, and snippets.

View Ocramius's full-sized avatar
🔬
In your repositories, watching your code. Always watching.

Marco Pivetta Ocramius

🔬
In your repositories, watching your code. Always watching.
View GitHub Profile
<?php
if (isset($_POST['strumento'][$cod_strum])) {
$element = new Zend_Form_Element_File('foo');
$element->setLabel('Upload an image:')
->setDestination('/home/dbstrumenti');
// ensure only 1 file
$element->addValidator('Count', false, 1);
// limit to 100K
$element->addValidator('Size', false, 102400);
// only JPEG, PNG, and GIFs
<?php
$someArray = array();
$result= $query->fetch(PDO::FETCH_ASSOC);
$someArray['id'] = $result['id'];
$result['id']= $query->fetch(PDO::FETCH_ASSOC);
$someVar = $result['id'];
var_dump($someArray == $someVar); // false
var_dump($someArray); // array('id' => 123);
// zend framework è in /var/www/lib/Zend mentre il file che contiene l'autoloader è nella root
<?php
// Setting include_path to add library to included dirs
set_include_path(realpath(__DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR .'Zend'.DIRECTORY_SEPARATOR. 'library') . PATH_SEPARATOR . get_include_path());
// Initializing autoloader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$dbh = new PDO('pgsql:user=garbezzano password=*a571992g* host=127.0.0.1 dbname=dbstrumenti');
?>
@Ocramius
Ocramius / zscroll.html
Created June 5, 2012 07:46
Scrolling along the Z-Axis
<html>
<head>
<title>Scrolling along the Z-Axis</title>
<!--
Example from http://eng.wealthfront.com/2012/03/scrolling-z-axis-with-css-3d-transforms.html
Assumes browser window is sized at a height of 400px (the size of the black box).
-->
<style>
body{height:600px;}
#viewport {
@Ocramius
Ocramius / zscroll.html
Created June 5, 2012 07:47 — forked from cers/zscroll.html
Scrolling along the Z-Axis
<html>
<head>
<title>Scrolling along the Z-Axis</title>
<!--
Example from http://eng.wealtfront.com
Assumes browser window is sized at a height of 400px (the size of the black box).
-->
<style>
body{height:600px;}
#viewport {
@Ocramius
Ocramius / Entity.php
Created June 24, 2012 15:55
Annotations in ZendFramework 2 and Doctrine
<?php
namespace BlitzEvent\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\Form\Anotation;
/**
*
* @ORM\Entity(repositoryClass="BlitzEvent\Repository\Event")
@Ocramius
Ocramius / di.create-definitions.php
Created June 26, 2012 16:32 — forked from SocalNick/di.create-definitions.php
ZF2 Di definition compiler
<?php
// in ZF2 project, place this in ./bin directory
chdir(dirname(__DIR__));
$zf2Path = (getenv('ZF2_PATH') ?: 'vendor/ZendFramework/library');
require_once $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
require_once $zf2Path . '/Zend/Loader/StandardAutoloader.php';
use Zend\Loader\AutoloaderFactory;
use Zend\Loader\StandardAutoloader;
@Ocramius
Ocramius / module.config.php
Created June 26, 2012 16:32 — forked from SocalNick/module.config.php
ZF2 Sample Application Configuration for compiled Di
<?php
return array(
// Other component configuration (i.e. router, controller, view_manager
'di' => array(
'definition' => array(
'runtime' => array(
'enabled' => false,
),
@Ocramius
Ocramius / Client.class.php
Created July 23, 2012 09:30 — forked from yiseli/Client.class.php
Doctrine - Empty proxy object values
<?php
namespace Model\Entities;
use Doctrine\Common\Collections\ArrayCollection;
class Client extends Entreprise
{
function __construct($id = null, $nom = null) {
parent::__construct($id, $nom);
}
@Ocramius
Ocramius / pr.md
Created September 18, 2012 15:22 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: