Skip to content

Instantly share code, notes, and snippets.

<?php
class DistanceOfTimeInWords
{
const MINUTES_IN_YEAR = 525600;
const MINUTES_IN_QUARTER_YEAR = 131400;
const MINUTES_IN_THREE_QUARTERS_YEAR = 394200;
const UP_TO_24_HOURS = 1440;
const UP_TO_48_HOURS = 2520;
const UP_TO_30_DAYS = 43200;
@defrag
defrag / gist:4547311
Created January 16, 2013 14:02
Beanstalkd command line process for listening to symfony2 bg jobs.
<?php
namespace PW\ApplicationBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand,
Symfony\Component\Console\Input\InputArgument,
Symfony\Component\Console\Input\InputInterface,
Symfony\Component\Console\Input\StringInput,
Symfony\Component\Console\Output\OutputInterface;
@defrag
defrag / AssetManager.php
Created November 26, 2012 10:12
Sample Asset Manager handling upload
<?php
namespace RE\AssetBundle\Model;
use Knp\Bundle\GaufretteBundle\FilesystemMap;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Gaufrette\FileStream\Local;
pw.event:
class: PW\ApplicationBundle\Model\EventManager
arguments:
environment: "%kernel.environment%"
config: "%pw.events%"
dm: "@doctrine.odm.mongodb.document_manager"
calls:
- [ setMode, [%pw_event.mode%] ]
- [ setRedis, ["@snc_redis.default_client"] ]
tags:
pw.event:
class: PW\ApplicationBundle\Model\EventManager
arguments:
environment: "%kernel.environment%"
config: "%pw.events%"
dm: "@doctrine.odm.mongodb.document_manager"
calls:
- [ setMode, [%pw_event.mode%] ]
- [ setRedis, ["@snc_redis.default_client"] ]
tags: