Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
<?php
namespace DigitalKanban\BaseBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Doctrine\ORM\EntityRepository;
use DigitalKanban\BaseBundle\Entity\User;
class UserType extends AbstractType {
/** @var $user sfGuardUser */
$user = $this->getUser()->getGuardUser();
@jmather
jmather / appendAround.js
Created July 24, 2012 13:25
Update to make AppendAround more efficient
jQuery(function( $ ){
var $$resize_callback_set = false;
var $$timer = null;
var $$callbacks = [];
$.fn.appendAround = function(opts){
return this.each(function(){
var $self = $( this ),
att = "data-set",
$set = $( "["+ att +"='"+ $self.closest( "["+ att +"]" ).attr( att ) + "']" );
class MediaServerFilter extends sfFilter
{
public function execute ($filterChain)
{
$filterChain->execute();
// Execute this filter only once
if ($this->isFirstCall())
{
// Filters don't have direct access to the request and user objects.
// You will need to use the context object to get them
@jmather
jmather / WelcomeController.php
Created August 5, 2012 03:22
How to scope out hierarchal structure in symfony2
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class WelcomeController extends Controller
{
public function indexAction()
{
@jmather
jmather / SecurityContext.php
Created August 5, 2012 12:35
SecurityContext isGranted explanation
<?php
/* ... */
final public function isGranted($attributes, $object = null)
{
if (null === $this->token) {
throw new AuthenticationCredentialsNotFoundException('The security context contains no authentication token. One possible reason may be that there is no firewall configured for this URL.'$
}
@jmather
jmather / deploy.rb
Created August 26, 2012 03:33
Config for easing capifony deploys
before 'symfony:composer:update', 'symfony:copy_vendors'
namespace :symfony do
desc "Copy vendors from previous release"
task :copy_vendors, :except => { :no_release => true } do
pretty_print "--> Copying vendors from previous release if exists"
run "if [ -d #{previous_release}/vendor ]; then cp -a #{previous_release}/vendor #{latest_release}/vendor; fi"
puts_ok
end
end
before 'symfony:composer:update', 'symfony:copy_vendors'
namespace :symfony do
desc "Copy vendors from previous release"
task :copy_vendors, :except => { :no_release => true } do
pretty_print "--> Copying vendors from previous release if exists"
run "cp -a #{previous_release}/vendor #{latest_release}/vendor"
puts_ok
@jmather
jmather / .bash_profile
Created August 29, 2012 18:33
Turn on agent forwarding automatically
AGENTRUNNING=`ps x | grep agent | grep -v grep`
if [ -z "$AGENTRUNNING" ]; then
/usr/bin/ssh-agent -s > $HOME/.ssh/agent-env.sh
fi
source $HOME/.ssh/agent-env.sh
@jmather
jmather / factories.yml
Created August 30, 2012 15:14
Extend user timeout in sf1
user:
class: myUser
param:
timeout: 7200