Skip to content

Instantly share code, notes, and snippets.

@rande
rande / gist:985705
Created May 22, 2011 17:48
Sonata Security - Roles definitions
sonata_admin:
access_control:
- { path: ^/admin/sonata/media/media/list$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_LIST], methods: null }
- { path: ^/admin/sonata/media/media/create$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_CREATE], methods: null }
- { path: ^/admin/sonata/media/media/update$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_UPDATE], methods: null }
- { path: ^/admin/sonata/media/media/batch$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_BATCH], methods: null }
- { path: ^/admin/sonata/media/media/(?P[^/]+?)/edit$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_EDIT], methods: null }
- { path: ^/admin/sonata/media/media/(?P[^/]+?)/delete$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_DELETE], methods: null }
- { path: ^/admin/sonata/media/media/(?P[^/]+?)/view$, roles: [ROLE_SONATA_MEDIA_ADMIN_MEDIA_VIEW], methods: null }
- { path: ^/admin/sonata/media/gallery/list$, roles: [ROLE_SONATA_MEDIA_ADMIN_GALLERY_LIST], methods: null }
@Thinkscape
Thinkscape / gist:1136563
Created August 10, 2011 11:05
Very simple performance comparison - arrays vs objects (PHP 5.3.6)
# php -v
PHP 5.3.6 (cli) (built: Mar 17 2011 20:58:15)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
# echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $s[] = array("name"=>"Adam","age"=>35); }; echo memory_get_peak_usage(); ' | php
655040
# echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $o = new ArrayObject; $o->name = "Adam"; $o->age = 35; $s[] = $o;} echo memory_get_peak_usage(); ' | php
887984
@jmather
jmather / SiteListBuilder.php
Created August 14, 2011 06:43
How to link a many-to-many properly in Symfony2 with Sonata Admin Bundle
<?php
namespace Majax\PortalBundle\Builder;
use Symfony\Bundle\DoctrineBundle\Registry;
class SiteListBuilder {
/** @var \Symfony\Bundle\DoctrineBundle\Registry */
private $orm;
public function __construct($orm)
@yobud
yobud / AddFulltextIndexesCommand.php
Created September 22, 2011 09:35
MATCH AGAINST for Doctrine DQL queries
<?php
# xxx/yyyBundle/Command/AddFulltextIndexesCommand.php
/**
* AddFulltextIndexesCommand.php
*
* @author Jérémy Hubert <jeremy.hubert@infogroom.fr>
* @since lun. 26 sept. 2011 09:23:53
*/
namespace xxx\yyyBundle\Command;
@adhipg
adhipg / countries.sql
Created January 12, 2012 11:41
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@oodavid
oodavid / README.md
Last active September 22, 2024 16:02 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@kkamkou
kkamkou / horizontal.phtml
Last active May 27, 2022 16:12
Zend Navigation for the Twitter Bootstrap
<?php
/**
* @author Kanstantsin A Kamkou (2ka.by)
* History:
* - 21.08.2012 Bootstrap 2.1.0 corrections
* - 31.03.2013 Acl check added
*/
$html = array('<ul class="nav">');
@aeurielesn
aeurielesn / gist:2511005
Created April 27, 2012 17:23
Retrying a jQuery.ajax() call
$.ajax({
url: '/echo/error/',
async: true,
// retryCount and retryLimit will let you retry a determined number of times
retryCount: 0,
retryLimit: 10,
// retryTimeout limits the total time retrying (in milliseconds)
retryTimeout: 10000,
// timeout for each request
timeout: 1000,
@rmrfself
rmrfself / transaction.php
Created May 19, 2012 07:27
How to make transactions in Doctrine 2 using Symfony 2
<?php
// Snippet for Symfony 2 application that uses Doctrine 2 to handle transactions
// It uses the names of the objects/doctrine repositories from the Beta 4 Manual of Symfony 2.
// Get the entity manager
$em = $this->getDoctrine()->getEntityManager();
// suspend auto-commit
$em->getConnection()->beginTransaction();
@jeroenherczeg
jeroenherczeg / bootstrap.php
Created June 19, 2012 12:44 — forked from kkamkou/horizontal.phtml
Zend Navigation for the Twitter Bootstrap
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initNavigation() {
// make sure the layout is loaded
$this->bootstrap('layout');
// get the view of the layout
$layout = $this->getResource('layout');
$view = $layout->getView();