Skip to content

Instantly share code, notes, and snippets.

Working from home...

Massimiliano Arione garak

Working from home...
View GitHub Profile
garak / controller.php
Created April 30, 2021 13:27
renderForm helper method for Symfony base controller
View controller.php
protected function renderForm(string $template, FormInterface $form, array $params = []): Response
$code = $form->isSubmitted() && !$form->isValid() ? Response::HTTP_UNPROCESSABLE_ENTITY : Response::HTTP_OK;
return $this->render($template, array_merge($params, ['form' => $form->createView()]), new Response(null, $code));
garak / rte.html
Created July 7, 2020 16:21
Pure JS rich text editor
View rte.html
<!doctype html>
<title>Rich Text Editor</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
garak /
Last active May 14, 2022 01:45
bitbucket pipeline configuration for a Symfony project

This configuration is for a project running Symfony (2 or 3)

I did the image after not founding anything suitable (it was a quick search). If you found a better one, tell me.

The parameter.yml.dist file is supposed to contain sensible default values. Only the password is replaced at runtime. If you need to replace other values, just add other sed commands to the script node.

I load fixtures before running tests because I rely on a "load once" strategy (I use a bundle to revert all changes done by my tests). If you prefer to load fixtures inside your tests, you can remove thas command from script

garak / Foo.php
Created February 16, 2017 13:40
uploadable with embedded
View Foo.php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
garak / list.html.twig
Last active July 18, 2020 05:50 — forked from tentacode/list.html.twig
Twig recursive macro
View list.html.twig
{% macro recursiveCategory(category) %}
{% import _self as self %}
<h4><a href="{{ path(category.route, category.routeParams) }}">{{ category }}</a></h4>
{% if category.children|length %}
{% for child in category.children %}
{{ self.recursiveCategory(child) }}
{% endfor %}
View ContactType.php
namespace Acme\DemoBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints;
class ContactType extends AbstractType
garak / DefaultControllerTest.php
Last active August 29, 2015 14:01
Testing facebook login with FOSFacebookBundle (functional test)
View DefaultControllerTest.php
namespace Acme\DemoBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
public function testLoginOK()
View WebTestCase.php
namespace MyNamespace\CoreBundle\Test;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase;
use Symfony\Component\Process\Process;
abstract class WebTestCase extends SymfonyWebTestCase
garak / RomanNumberTest.php
Created June 27, 2012 08:05
test usati per il code kata di giugno 2012 al PUG Roma
View RomanNumberTest.php
#require_once __DIR__ . '/../RomanNumber.php';
class romanNumberTest extends \PHPUnit_Framework_TestCase
public function testOne()
$this->assertEquals('I', rnConvert(1));
garak / estrazione_pug.php
Created March 29, 2012 12:23
script per estrare un biglietto gratis per il phpDay/jsDay
View estrazione_pug.php
$p = array(
// gennaio