Skip to content

Instantly share code, notes, and snippets.

View benglass's full-sized avatar

Ben Glassman benglass

View GitHub Profile
var eventDispatcher = function() {
var events = {};
var getEvent = function(name) {
if ( ! events[name]) {
events[name] = $.Callbacks();
}
return events[name];
};
var addListener = function(eventName, fn) {
getEvent(eventName).add(fn);
<?php
$numcols = intval($argv[1]) or die('provide a total column #');
$items = range('a', 'z');
$itemsPerCol = ceil(count($items) / $numcols);
for ($i = 1; $i <= $numcols; $i++) {
$start = ($i - 1) * $itemsPerCol;
$colItems = array_slice($items, $start, $i == $numcols ? null : $itemsPerCol);
echo sprintf('Column %d is %d items', $i, count($colItems));
{% set _isAuthenticated = app.user and is_granted("IS_AUTHENTICATED_REMEMBERED") %}
<ul>
{% if _isAuthenticated %}
<li><a href="{{ path('fos_user_security_logout') }}">Logout</a></li>
<li class="divider">|</li>
<li><a href="{{ path('fos_user_profile_edit') }}"><span class="truncate">My </span>Account</a></li>
{% else %}{# not authenticated #}
<li><a href="{{ path('fos_user_security_login') }}">Login</a></li>
{% endif %}
<?php
class ContentAwareFactory extends RouterAwareFactory
public function createFromNode(NodeInterface $node)
{
$item = $this->createItem($node->getName(), $node->getOptions());
if (empty($item)) {
return null;
@benglass
benglass / gist:7818019
Last active December 30, 2015 10:48
These are the commands that are run before the phpunit tests in order to ensure that the sqlite db and phpcr repository are set up
app/console doctrine:database:drop -e=test --force
app/console doctrine:database:create -e=test
app/console doctrine:phpcr:init:dbal -e=test
app/console doctrine:phpcr:workspace:create standard_test -e=test
app/console doctrine:phpcr:repository:init -e=test
<?php
class StaffController
{
/**
* @Route("/about/{slug}", name="staff_detail")
* @ParamConverter("staff", class="VdwStaffBundle:Staff")
* @Cache(expires="tomorrow", public="true")
*/
public function addRouteEnhancer(RouteEnhancerInterface $enhancer, $priority = 0)
{
echo get_class($enhancer);
echo PHP_EOL;
if (empty($this->enhancers[$priority])) {
$this->enhancers[$priority] = array();
}
$this->enhancers[$priority][] = $enhancer;
$this->sortedEnhancers = array();
<service id="vdw_cms.route_enhancer.website_template" class="Vdw\CmsBundle\Enhancer\WebsiteTemplateEnhancer">
<argument type="service" id="vdw_cms.manager.website" />
<tag name="dynamic_router_route_enhancer" priority="50" />
</service>
security:
access_decision_manager:
strategy: unanimous
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your need!
*/