This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\DependencyInjection\DefinitionDecorator; | |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | |
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; | |
use Symfony\Component\DependencyInjection\Reference; | |
use Symfony\Component\DependencyInjection\ContainerInterface; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use JMS\DiExtraBundle\Annotation as DI; | |
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | |
/** @DI\Service */ | |
class QSAListener | |
{ | |
private $blacklist; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function array_diff_simple($a, $b) | |
{ | |
$r = array(); | |
foreach($a as $key => $val) { | |
if(!isset($b[$key])) { | |
$r[$key] = $val; | |
} else { | |
if(is_array($b[$key]) && !is_array($val)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first sphinx | |
brew install sphinx | |
# the formula does not install libsphinxclient :/ | |
wget http://sphinxsearch.com/files/sphinx-2.0.4-release.tar.gz | |
tar xzf sphinx-2.0.4-release.tar.gz | |
cd sphinx-2.0.4-release/api/libsphinxclient/ | |
CXXCPP="gcc -E" ./configure --prefix=/usr/local | |
make | |
make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// List models | |
echo implode(', ', Doctrine::loadModels(sfConfig::get('sf_lib_dir') . '/model/')); | |
// List models without Base* ones | |
$models = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function extractVimeoInformations($videoID, $fieldToExtract = 'id') | |
{ | |
$apiExtraction = unserialize(file_get_contents(sprintf('http://vimeo.com/api/v2/video/%s.php', $videoID))); | |
return $apiExtraction[0]; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync --exclude-from=<rsync-dir>/rsync_exclude.txt --include-from=<rsync-dir>/rsync_include.txt --files-from=<rsync-dir>/rsync.txt -e ssh -p <port> ./ <user><host>:<dir> | |
rsync --dry-run -azC --force --delete --progress --exclude-from=config/rsync_exclude.txt -e "ssh -p22" ./ [email protected]:/destination/path/httpdocs/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo_route: | |
url: /location-:url | |
options: { segment_separators: ['/', '.', '-'] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = $em->createQuery('SELECT ....') | |
->setMaxResults(1); | |
try { | |
$product = $query->getSingleResult(); | |
} catch (\Doctrine\Orm\NoResultException $e) { | |
$product = null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\Translation\TranslatorInterface; | |
function format(\DateTime $date, TranslatorInterface $translator) | |
{ | |
$diff = date_create()->diff($date); | |
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s; | |
$format = $translator->transChoice('reldate', $seconds); |
NewerOlder