Skip to content

Instantly share code, notes, and snippets.

View COil's full-sized avatar
🎯
Focusing

Loïc Vernet COil

🎯
Focusing
View GitHub Profile
@COil
COil / gist:5004469
Last active December 14, 2015 01:09
Twig C extension benchmark 1/2
<h3>Categories</h3>
<ul>
{% for rankLevel1, field in form.datas.Category.choices %}
{% include 'ThemesBundle:Search:_group_tree.html.twig' with {'form': form, 'widget': 'Category', 'rankLevel1': rankLevel1, 'level': 1, 'field': field } %}
{% endfor %}
</ul>
@COil
COil / gist:3860246
Created October 9, 2012 17:38
start() of Session.php
/**
* Starts the session storage.
*
* @api
*/
public function start()
{
if (true === $this->started) {
return;
}
@COil
COil / gist:2730653
Created May 19, 2012 12:24
Bash script to generate doctrine files for a given entity
#!/bin/bash
clear;
echo "> Generating the Doctrine files for a given Entity, be careful that the entities are camel-cased"
# Testing arguments
EXPECTED_ARGS=1
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: ./`basename $0` MyEntity"
@COil
COil / gist:1780897
Created February 9, 2012 16:24
Update Symfony2 script
#!/bin/bash
clear;
echo "> Update Symfony2 by getting the last vendors files and additional deps"
date
# Testing arguments
EXPECTED_ARGS=1
E_BADARGS=65
if [ $# -ne $EXPECTED_ARGS ]
then
@COil
COil / gist:1779871
Created February 9, 2012 13:10
PR Symfony, add a baseServerUrl() function in Request
<div>
<a href="{{ job.url }}">
<img src="{{ app.request.scheme ~ '://' ~ app.request.host }}{{ asset(job.webPath) }}"
alt="{{ job.company }} logo" />
</a>
</div>
-->
<div>
@COil
COil / gist:1694305
Created January 28, 2012 13:30
Load fixtures with Symfony2, snippet 05
<?php
namespace COil\Jobeet2Bundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use COil\Jobeet2Bundle\DataFixtures\ORM\LoadJobeet2Data;
use COil\Jobeet2Bundle\Entity\Job as Job;
class LoadJobData extends LoadJobeet2Data implements OrderedFixtureInterface
@COil
COil / gist:1694298
Created January 28, 2012 13:27
Load fixtures with Symfony2, snippet 04
# /src/YourNameSpace/YourBundle/Datafixtures/fixtures/jobs.yml
Job:
job_sensio_labs:
Category: programming
type: full-time
company: Sensio Labs
logo: sensio-labs.gif
url: http://www.sensiolabs.com/
position: Web Developer
location: Paris, France
@COil
COil / gist:1694282
Created January 28, 2012 13:19
Load fixtures with Symfony2, snippet 03
<?php
namespace COil\Jobeet2Bundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use COil\Jobeet2Bundle\DataFixtures\ORM\LoadJobeet2Data;
use COil\Jobeet2Bundle\Entity\Category as Category;
@COil
COil / gist:1694262
Created January 28, 2012 13:12
Load fixtures with Symfony2, snippet 02
# /src/YourNameSpace/YourBundle/Datafixtures/fixtures/categories.yml
Category:
design:
name: Design
programming:
name: Programming
manager:
name: Manager
administrator:
name: Administrator
@COil
COil / gist:1694230
Created January 28, 2012 13:01
Load fixtures with Symfony2, snippet 01
<?php
namespace COil\Jobeet2Bundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Yaml\Yaml;
abstract class LoadJobeet2Data extends AbstractFixture implements ContainerAwareInterface