> beautiful code & photos

about <

Posts tagged: code

To rewind, or ! (to rewind)

Lately, I was missioned to integrate a vendor PHP SDK that is transport-agnostic as it implements HTTPlug. Pretty cool.

Everything went well until I found out that the SDK used a response reader method helper which is:

 * @param ResponseInterface $response
 * @return stdClass
private function handleResponse(ResponseInterface $response)

    $stream = $response->getBody()->getContents();

    return json_decode($stream);

First issue: I can't pick the response format, I'm forced to deal with the object deserialization version of the JSON payload. This is okay but not completely since the structure of the JSON may vary if my peers

> Continue Reading

Link ID fields in EasyAdmin

If you also use EasyAdmin and are exhausted by clicking twice to see an entity ID when on the entity index page, you can use this small tweak to have your index page generate the detail page link on the ID field.

For this, simply override the template crud/field/id.html.twig.  
The original value is currently this:

{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{# this template is used to display Doctrine entity primary keys #}
{{ field.formattedValue }}

Instead, you could replace its content with this:

> Continue Reading

Cross-region & cross-account AWS resources Terraform planning

Hey, it's been a while, right?

Lately, I'm leading some big changes in our infrastrure since I'm wrapping a Blue/Green deployment into another one. Uh?

Long story short: our product runs on AWS ECS Docker containers, and because we have one sub-domain per app instance, we use Apache wildcard sub-domains. Meaning a single container handles traffic from many clients/instances. We already have a Blue/Green deployment process in place but at the Docker container level, not at the client level. The idea is to entirely duplicate the whole stack (with all its flaws) and a sub-domain pointing to

> Continue Reading

MySQL: adding an index on a big-ass table

Okay, I'll admit it: SQL and big data things aren't at the top of my skillset.

No earlier than today, I resolved an issue we had in our customer databases: adding a missing index.
Seems easy at first but if the table is HUGE (yea, 8GB+ is big for me) with about 246MM rows (!!), it gets damn slow and the downtime doesn't last for an eye blink.

Reminder: ALTER TABLE allows read operations while altering the table then blocks reads and writes ops when the alteration is done and needs to go live. This may vary according to the configuration

> Continue Reading

JS: Singleton as a module

When you develop a NodeJS application, you probably get to work with services and as much as possible with service dependency injection.
As I worked quite a lot with Symfony lately, I wanted to be able to manage my NodeJS services as it should be, and in some case, like a database connection: a single instance for the whole script.

I quicky looked onto Internet to see how to build a singleton in JavaScript (pardon my weak skills in this language) and I quickly found what I was (almost) looking for.

Code examples provided in the different posts I've read

> Continue Reading

PHP: Projet Silex – Templating

Oula, si vous aviez cru que le projet était tombé à l'eau, et bien non. Très très occupé ces derniers mois car je vis maintenant à New York et j'ai pas vraiment eu le temps de rédiger. Ni de trop avancer d'ailleurs.
Mais me revoilà, j'ai pas mal bossé ces dernières semaines et le projet a beaucoup changé depuis la dernière fois mais il est maintenant abouti (enfin). Pour les fidèles (si il en a encore), on retrouve encore et toujours notre road map habituelle :

Road map du projet

  1. Pré-requis et architecture
  2. Configuration de Silex
  3. Jouons avec Silex
  4. Ecriture de
> Continue Reading