Skip to content

Instantly share code, notes, and snippets.

@beberlei
beberlei / MyWebTestCase.php
Created September 17, 2011 12:14
Easily Inject authenticated Symfony User into functional test
<?php
use Liip\FunctionalTestBundle\Test\WebTestCase;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @group functional
*/
@jmikola
jmikola / SecurityLastActivityListener.php
Created November 11, 2011 21:12
Custom Symfony2 Voter for recent-activity and has-password security checks
<?php
namespace Acme\DemoBundle\Listener;
use Acme\DemoBundle\Security\Authorization\Voter;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@beberlei
beberlei / packages_phpunit.php
Created January 4, 2012 23:33
Script to generate packages.json of PHPUnit + dependencies
<?php
/**
* Generates a package JSON that allows to install phpunit + dependencies
* from versions 3.5.12 up to now.
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
*
* @example
*
* {
@igorw
igorw / gist:2145730
Last active May 22, 2023 13:23
Composer PR Template

Composer is a new dependency manager for PHP. It allows you to specify dependencies on a per-project basis. It takes lots of inspiration from NPM and ruby's bundler.

All you need to support composer is a composer.json file. In order to allow easy installation, the repository needs to be added to packagist, which is the standard repository for composer. Packagist will fetch all the versions from your github repository tags.

Once it has been added, adding {PROJECT} to a project will be as easy as creating this composer.json file in the project's directory:

{
    "require": {
        "{VENDOR}/{PROJECT}": "{VERSION}"

}

@fat
fat / Tokenahead.less
Created April 18, 2012 04:01
Tokenahead - ghetto typeahead with facebook-like tokens 4 @couch <3
// Tokenahead.less
// ---------------
.tokenahead {
cursor: text;
overflow: hidden;
height: auto;
padding-bottom: 0;
border-color: @inputBorder;
}
@merk
merk / AbstractInvoiceLineType.php
Created July 6, 2012 06:07
Symfony2 Form Polycollection for use with objects in an inheritance structure
<?php
// ...
class AbstractInvoiceLineType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...
@fabpot
fabpot / pr-labels.js
Created December 10, 2013 08:50
Displays pull requests labels on Github. Change 'YOU_API_TOKEN' to a Github token or remove the query parameter altogether (but you will run out of calls very fast).
// ==UserScript==
// @name Adds Labels on Github Pull Request
// @namespace http://fabien.potencier.org
// @include https://github.com/*/*/pulls*
// @version 2
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
$(function() {
$(".pulls-list .list-group-item h4").each(function() {
var pull_request = this;