Skip to content

Instantly share code, notes, and snippets.

View adrienlucas's full-sized avatar

Adrien LUCAS adrienlucas

View GitHub Profile
@adrienlucas
adrienlucas / Controller.tpl.php
Created July 24, 2023 08:59
MakerBundle extension to add `make:standalone-controller`
<?= "<?php\n" ?>
namespace <?= $namespace; ?>;
<?= $use_statements; ?>
<?php if ($is_standalone) { ?>
#[AsController()]
<?php } ?>
class <?= $class_name; ?><?= !$is_standalone ? ' extends AbstractController': '' ?>
@adrienlucas
adrienlucas / WithTwigController.php
Created July 20, 2023 13:44
`make:controller --standalone --invoke`
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route;
use Twig\Environment;
#[AsController]
@adrienlucas
adrienlucas / ide-scripting.groovy
Created February 2, 2023 08:43
"Copilot More PHP Context" for IntelliJ IDE Console
// "Copilot More PHP Context"
// Adds the content of the imported PHP classes as a comment to the end of the opened file
// in order to provide more context to the Copilot plugin.
// This Groovy script is meant to be used with the IntelliJ IDE Console plugin.
import java.io.File
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.command.WriteCommandAction
@adrienlucas
adrienlucas / keybase.md
Created January 4, 2019 11:41
Keybase.io proof

Keybase proof

I hereby claim:

  • I am adrienlucas on github.
  • I am adrienlucas (https://keybase.io/adrienlucas) on keybase.
  • I have a public key ASCu32wHMOVwGIyjYn8HN2oWjHucMDFQuqgzU-cqGpdX3wo

To claim this, I am signing this object:

@adrienlucas
adrienlucas / thenable.js
Created June 12, 2017 11:38
jQuery Thenable stacking POC
import jQuery from 'jquery';
it('stacks several promises with one rejection', () => {
const p1 = new jQuery.Deferred();
const p2 = new jQuery.Deferred();
const p3 = new jQuery.Deferred();
const stack = jQuery.when(...promises);
expect(stack.state()).toBe('pending');
@adrienlucas
adrienlucas / true_rand.php
Created March 3, 2016 13:44
True Random in PHP
<?php
/**
* Generate a true random integer.
* To be used as a rand() replacement as it behave exactly the same.
*
* int true_rand(void)
* int true_rand(int $min, int $max)
*
* It uses the HotBits webservice from FourmilLab as randomness provider
* based on radioactive decay. See https://www.fourmilab.ch/hotbits/.
We couldn’t find that file to show.
@adrienlucas
adrienlucas / .xprofile
Created May 4, 2015 17:13
Disable touchscreen with .xprofile
xinput disable `xinput list | grep "Touchscreen" | sed -E 's/^.*id=([0-9]+).*$/\1/'`
@adrienlucas
adrienlucas / poc-bash-colors.sh
Created May 4, 2015 17:11
Bash colors PoC script
#!/bin/bash
echo ---BG---40---41---42---43---44---45---46---47
for i in {30..37} # foreground
do
echo -n -e FG$i-
for j in {40..47} # background
do
echo -n -e '\E['$i';'$j'm foo\E[0m'
done
@adrienlucas
adrienlucas / pagebrowser.html.twig
Created September 4, 2014 09:11
Twig macro to display a pagination, aka page browser.
{*
Twig macro to display a pagination, aka page browser.
Usage :
First you have to import the macro using "import" :
{% from 'AcmeBundle:Default:Macro/pagebrowser.html.twig' import pagebrowser %}
Then, call the function :
{{ pagebrowser(route, routeParams, totalPages, currentPage, browserSize) }}
Where :
route : the list route that have the page param, usually 'app.request.attributes.get('_route')'