Skip to content

Instantly share code, notes, and snippets.

View tyx's full-sized avatar

Timothée Barray tyx

View GitHub Profile
@tyx
tyx / CustomTranslationListener.php
Last active November 27, 2019 08:41
symfony runtime translator
<?php
declare(strict_types=1);
namespace Oxatis\Internationalization\Ui;
use Oxatis\Internationalization\Infra\RuntimeTranslator;
use Oxatis\SharedKernel\Common\Domain\Lang;
use Oxatis\ShopSettings\Infra\ShopConfigurationReader;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@tyx
tyx / problem.php
Last active December 22, 2015 10:59
<?php
function getFormatter($dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null)
{
$formatValues = array(
'none' => \IntlDateFormatter::NONE,
'short' => \IntlDateFormatter::SHORT,
'medium' => \IntlDateFormatter::MEDIUM,
'long' => \IntlDateFormatter::LONG,
'full' => \IntlDateFormatter::FULL,
@tyx
tyx / gist:6461136
Created September 6, 2013 08:38
Count lines number on big files
<?php
$file = new SplFileObject("mybigfile.csv");
// Store flags and position
$flags = $file->getFlags();
$current = $file->key();
// Prepare count by resetting flags as READ_CSV for example make the tricks very slow
$file->setFlags(null);
->andWhere('s.id = (SELECT id FROM (SELECT id, MAX(shop.rating) FROM Atipik\BaseBundle\Entity\Shop shop WHERE shop.brand = s.brand) sub)')
$.fn.vectorMap('addMap', 'france_fr', {"width":634,"height":578,"pathes":{
"midi-pyrenees":{
"path":"m 247.469,347.312 -4.156,1.938 -0.594,0.094 0.125,0.188 -1.344,1.156 v 2.156 l 1.75,1.938 -1.75,3.125 -1.562,1 -0.219,1.938 -3.312,0.406 0.188,2.125 1.188,0.406 -2.75,3.906 -4.281,0.375 -0.19,2.937 -1.781,1.75 -0.969,2.562 -3.906,0.188 1.562,5.844 1.969,4.312 -4.312,0.781 -2.938,-1.75 -1.375,4.469 2.156,2.344 -0.968,3.719 -1.188,1.375 0.812,2.344 -3.719,0.781 -2.938,0.781 0.781,2.719 -1.938,0.594 -1,0.969 -2.938,-2.906 -5.844,0.562 -1.562,2.75 -3.531,0.375 -3.312,0.594 -1.375,-1.938 -3.125,3.125 -2.312,-1.969 -1.375,2.938 0.188,2.531 -2.156,0.594 -0.969,-1.375 -0.969,-2.938 -2.75,2.344 -1.938,-0.781 -2.156,0.406 -1.938,2.344 2.312,3.906 -1.562,1.562 0.594,3.312 -1.938,2.531 -1.375,3.719 1.562,2.75 5.281,0.375 3.312,5.469 -2.156,1.969 1.562,2.344 2.344,3.5 -1.938,2.531 -3.125,7.031 -5.281,4.5 1.375,2.75 -1.188,0.781 -2.906,-0.594 -0.812,6.438 -1.562,1.188 -0.312,4.031 0.5,-0.281 3.312,1.969 3.906,2.938 0.375
<?php
public static function generateShortKey($input)
{
$base32 = array (
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5'
);
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=hh.init";
document.body.appendChild(script);
}
window.onload = loadScript;
var hh = (function() {
init: function() {
// Ouvre le premier lien enfant de l'élément cible
// Reproduit le comportement des navigateurs (ctrl ou cmd ou middleclick = nouvel onglet)
$('.line-click').live('click', function(e){
e.stopPropagation();
href = $(this).children('a:first').attr('href');
if (e.ctrlKey || e.metaKey || e.which == 2) {
window.open(href);
} else {
window.location = href;
}
<?php
namespace App\GtsBundle\Form\Transformer;
use Symfony\Component\Form\ValueTransformer\BaseValueTransformer;
class DoctrineCollectionTransformer extends BaseValueTransformer
{
public function reverseTransform($ids, $collection)
{
diff --git a/Admin/Admin.php b/Admin/Admin.php
index a532554..4d41b1b 100644
--- a/Admin/Admin.php
+++ b/Admin/Admin.php
@@ -207,7 +207,7 @@ abstract class Admin extends ContainerAware
'name' => $this->getBaseRouteName().'_list',
'pattern' => $this->getBaseRoutePattern().'/list',
'defaults' => array(
- '_controller' => $this->getBaseControllerName().':list'
+ '_controller' => $this->getBaseControllerName().'::listAction'