Skip to content

Instantly share code, notes, and snippets.

Kris Wallsmith kriswallsmith

Block or report user

Report or block kriswallsmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View 01_example.php
class WidgetManager
private $em;
private $factory;
private $manipulator;
private $dispatcher;
public function __construct(ObjectManager $em, SnapshotFactory $factory, WidgetManipulator $manipulator, EventDispatcherInterface $dispatcher)
kriswallsmith / 01_mixins_Secure.js
Last active Aug 29, 2015
My first bit of React code worth sharing.
View 01_mixins_Secure.js
var React = require('react');
var Router = require('react-router');
var SessionStore = require('../stores/SessionStore');
var Stash = require('../utils/Stash');
function authentication(transition) {
if (!SessionStore.isLoggedIn()) {
Stash.set('onLogin', transition.retry);
return false;
kriswallsmith / gist:4e7ea1cb1ec83f5203e1
Last active Aug 29, 2015
These are the Neo4j Cypher queries Assetic would run
View gist:4e7ea1cb1ec83f5203e1
// what to recompile when as asset changes
MATCH (changed)<-[:INCLUDES*]-(recompile)
WHERE changed.source = "..." AND <> NULL
RETURN recompile
// determine an asset's aggregate mtime
MATCH (root)-[:INCLUDES*]->(include)
WHERE root.source = "..."
RETURN max(collect(include.mtime) + root.mtime)
kriswallsmith / default.vcl.erb
Created Feb 27, 2014
Here's a decent Chef workaround for Varnish's lack of support for ACL behind a proxy.
View default.vcl.erb
sub vcl_recv {
if (req.url ~ "(?i)^/admin" && req.http.x-forwarded-for !~ "\b(<%={ |ip| Regexp.escape(ip) }.join('|') %>)$") {
error 750 "Moved Temporarily";
sub vcl_error {
if (obj.status == 750) {
set obj.http.Location = "/";
set obj.status = 302;
kriswallsmith / 01_before.php
Created Sep 10, 2013
I could really go for an array_index() function right now.
View 01_before.php
$widgets = array_combine(
function($widget) {
return $widget->getId();
kriswallsmith / test.php
Last active Dec 20, 2015
A test harness for your Symfony2 project. Runs functional tests in chunks.
View test.php
#!/usr/bin/env php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput as Input;
use Symfony\Component\Console\Input\InputOption as Option;
require_once __DIR__.'/../vendor/autoload.php';
/** Outputs and runs a command. */
kriswallsmith / gist:5819198
Last active Dec 18, 2015
How do you walk a paginated API?
View gist:5819198
function walk($callback)
$page = 1;
do {
$results = fetch($page++, 100);
foreach ($results as $result) {
call_user_func($callback, $result);
kriswallsmith / QSAListener.php
Created Aug 8, 2012
implements QSA on Symfony2 redirects
View QSAListener.php
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/** @DI\Service */
class QSAListener
private $blacklist;
View RouteSecurityListener.php
namespace OpenSky\Bundle\MainBundle\Listener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\SecurityContextInterface;
* Listens to kernel.request after the router and checks required role.
View 00_DefaultControllerTest.php
namespace Kris\JunkBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
* @dataProvider asdf
You can’t perform that action at this time.