Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working from home...

Massimiliano Arione garak

:octocat:
Working from home...
View GitHub Profile
@garak
garak / README.md
Last active May 14, 2022
bitbucket pipeline configuration for a Symfony project
View README.md

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
garak / rte.html
Created Jul 7, 2020
Pure JS rich text editor
View rte.html
<!doctype html>
<html>
<head>
<title>Rich Text Editor</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
View locator.js
$().ready(function() {
// search address and get latitude/longitude
var searchLocations = function(e) {
var $form = $(this);
var address = $('input#address').val();
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var center = results[0].geometry.location;
@garak
garak / controller.php
Created Apr 30, 2021
renderForm helper method for Symfony base controller
View controller.php
<?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
garak / strtotime.php
Created May 31, 2011
never use '+1 month' and '-1 month' in strtotime. It's just bugged
View strtotime.php
<?php
// tried this today, 31 May 2011
echo "\n";
echo date('Y-m-d', strtotime('first day of next month')); // correct
echo "\n";
echo date('Y-m-d', strtotime('+1 month')); // wrong! output is 2011-07-01
echo "\n";
@garak
garak / list.html.twig
Last active Jul 18, 2020 — forked from tentacode/list.html.twig
Twig recursive macro
View list.html.twig
{% macro recursiveCategory(category) %}
{% import _self as self %}
<li>
<h4><a href="{{ path(category.route, category.routeParams) }}">{{ category }}</a></h4>
{% if category.children|length %}
<ul>
{% for child in category.children %}
{{ self.recursiveCategory(child) }}
{% endfor %}
@garak
garak / Foo.php
Created Feb 16, 2017
uploadable with embedded
View Foo.php
<?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;
/**
View WebTestCase.php
<?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
garak / RomanNumberTest.php
Created Jun 27, 2012
test usati per il code kata di giugno 2012 al PUG Roma
View RomanNumberTest.php
<?php
#require_once __DIR__ . '/../RomanNumber.php';
class romanNumberTest extends \PHPUnit_Framework_TestCase
{
public function testOne()
{
$this->assertEquals('I', rnConvert(1));
}
@garak
garak / estrazione_pug.php
Created Mar 29, 2012
script per estrare un biglietto gratis per il phpDay/jsDay
View estrazione_pug.php
<?php
$p = array(
// gennaio
'arnaldo',
'giorgio',
'antonio',
'david',
'jacopo',
'luca',