Skip to content

Instantly share code, notes, and snippets.

View chalasr's full-sized avatar

Robin Chalas chalasr

View GitHub Profile
@LeCoupa
LeCoupa / redis_cheatsheet.bash
Last active April 17, 2025 11:09
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@ericclemmons
ericclemmons / example.md
Last active September 20, 2024 12:46
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 Summary Goes Here
@chalasr
chalasr / splat_operator.php
Last active April 11, 2016 13:26
function with dynamic number of type-hinted arguments using the splat operator PHP 5.6
<?php
function splat(array ...$args) {
foreach ($args as $arg) {
print_r($arg);
}
}
splat(['firstArray'], ['secondArray']);
// Output: Array( [0] => firstArray ) Array( [0] => secondArray )
@chalasr
chalasr / AcmeExtension.php
Created February 29, 2016 22:09
Load configuration files depending on host in Symfony
// src/AcmeBundle/DependencyInjection/AcmeExtension.php
<?php
namespace AcmeBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@chalasr
chalasr / EnhancedRepository.php
Last active September 26, 2023 00:59
Implements a custom EntityRepository using Factory in Symfony2.6+
<?php
namespace App\Util\Doctrine\Repository;
use App\Util\Doctrine\Entity\AbstractEntity;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@sroze
sroze / MyCommand.php
Last active June 6, 2021 13:58
Symfony Command that read file from file name or STDIN
<?php
namespace AmceBundle\Command;
class MyCommand
{
// ...
protected function execute(InputInterface $input, OutputInterface $output)
{
@webdevilopers
webdevilopers / PersonAdmin.php
Last active March 29, 2016 21:52
Using Sonata Admin sonata_type_model_autocomplete property and callback option to create custom query with datagrid querybuilder
<?php
namespace AppBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
class PersonAdmin extends Admin
{
protected function configureDatagridFilters(DatagridMapper $filterMapper)
@chalasr
chalasr / ApplicationPersonneBundle:CRUD:list.html.twig
Last active March 24, 2022 11:23
Autocompletion AJAX for SonataAdminBundle $datagridMapper filters
{% extends 'SonataAdminBundle:CRUD:base_list.html.twig' %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
$(document).ready(function(){
var MIN_LENGTH = 3;
var datalistFirst = $('<ul class="select2-results autoResults" role="listbox" id="datalist_filter_firstname_value"></ul>');
var datalistName = $('<ul class="select2-results autoResults" role="listbox" id="datalist_filter_name_value"></ul>');
$('#filter_name_value').after(datalistName);
@soyuka
soyuka / ObjectListener.php
Last active July 12, 2023 06:17
Streaming big json files the good way with php with https://soyuka.me/streaming-big-json-files-the-good-way/
<?php
namespace Fry;
use JsonStreamingParser\Listener;
/**
* This implementation allows to process an object at a specific level
* when it has been fully parsed
*/
class ObjectListener implements Listener
{
@v-jacob
v-jacob / MailTestHelper.php
Last active November 29, 2021 04:27
Mailhog PHPUnit Test Helper
<?php
use GuzzleHttp\Client;
trait MailTestHelper
{
/**
* @var \GuzzleHttp\Client
*/
protected $client;