Skip to content

Instantly share code, notes, and snippets.

@jmoz
jmoz / gist:974666
Created May 16, 2011 15:34
Logger observer
<?php
class ClientSymfonyLoggerObserver implements SplObserver {
private function update(SplSubject $subject) {
sfContext::getInstance()->getLogger()->info("Calling service " . get_class($subject->getService()) . " with url {$subject->getService()->getUrl()}");
}
}
@jmoz
jmoz / nginx 301
Created August 23, 2011 21:47
Nginx 301
server {
listen 80;
server_name vietnameseinshoreditch.co.uk;
rewrite ^ http://shoreditchvietnamese.co.uk$request_uri? permanent;
}
@jmoz
jmoz / Imagick stripImage.php
Last active September 26, 2015 22:28
Imagick stripImage
<?php
$file = '/home/moz/Desktop/canon-ixus.jpg';
$i = new Imagick($file);
print_r($i->getImageProperties('exif:*'));
$i->stripImage();
$i->writeImage($file . '2');
$i->readImage($file . '2');
@jmoz
jmoz / symfony2_4sq-1.php
Last active September 27, 2015 01:38
Symfony2 Foursquare venuehistory command
<?php
namespace JMOZ\FoursquareBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use JMOZ\FoursquareBundle\Entity\Checkin;
@jmoz
jmoz / LoadSecurityData.php
Created December 2, 2011 16:24
LoadSecurityData
<?php
namespace TimeOut\Bundle\SecurityBundle\DataFixtures;
use Doctrine\Common\DataFixtures\FixtureInterface;
use TimeOut\Bundle\SecurityBundle\Entity\User;
use TimeOut\Bundle\SecurityBundle\Entity\Role;
/**
* Load test users.
@jmoz
jmoz / role.php
Created December 2, 2011 15:48
Role
<?php
namespace JMOZ\Bundle\SecurityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\Role\RoleInterface;
/**
* Role Entity
*
@jmoz
jmoz / UserTest.php
Created December 2, 2011 15:54
UserTest
<?php
namespace JMOZ\Bundle\SecurityBundle\Tests\Functional;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use JMOZ\Bundle\SecurityBundle\Entity\User;
use JMOZ\Bundle\SecurityBundle\DataFixtures\LoadSecurityData;
/**
* @author James Morris <james@jmoz.co.uk>
@jmoz
jmoz / User.php
Created December 2, 2011 16:04
User
<?php
namespace JMOZ\Bundle\SecurityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\UserBundle\Model\User as BaseUser;
/**
@jmoz
jmoz / config.yml
Created December 7, 2011 18:05
config.yml
jms_security_extra:
expressions: true
method_access_control:
'^TimeOutTaxonomyAdminBundle:Default:.*': 'hasRole("ROLE_TAXONOMY_VIEW")'
@jmoz
jmoz / hookspost-receive
Created July 4, 2012 16:48
Git hooks post-receive
# crucial to allow the install.sh script to update Silex
unset GIT_DIR
GIT_WORK_TREE=/home/myuser/mysilexapp.git git checkout -f
# I like to do a sanity check of the files as there's no output from git checkout
ls -la /home/myuser/mysilexapp/
# execute an install script seperating project logic from git
/home/myuser/mysilexapp/install.sh