Skip to content

Instantly share code, notes, and snippets.

@soyuka
soyuka / PropertyMetadataFactory.php
Created February 18, 2021 13:36
API Platform use the Model namespace for the API and the Entity namespace for doctrine
<?php
declare(strict_types=1);
namespace App\Metadata;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
final class PropertyMetadataFactory implements PropertyMetadataFactoryInterface
@soyuka
soyuka / index.php
Created December 14, 2020 08:30
API Platform bootstrap
<?php
require './vendor/autoload.php';
use ApiPlatform\Core\Action\EntrypointAction;
use ApiPlatform\Core\Action\ExceptionAction;
use ApiPlatform\Core\Action\PlaceholderAction;
use ApiPlatform\Core\Api\IdentifiersExtractor;
use ApiPlatform\Core\Api\IdentifiersExtractorInterface;
use ApiPlatform\Core\Api\OperationType;
@soyuka
soyuka / stresstest.js
Last active September 11, 2020 16:25
Stresstest event source
const { Transform } = require('stream');
const http = require('http')
function toDataString(data) {
if (typeof data === 'object') return toDataString(JSON.stringify(data));
return data
.split(/\r\n|\r|\n/)
.map(line => `data: ${line}\n`)
.join('');
}
@soyuka
soyuka / composer.json
Last active June 12, 2020 14:02
Patch a composer vendor on the fly
"scripts": {
"post-update-cmd": "cd vendor/symfony/serializer && cat ../../../serializer.patch | patch"
}
@soyuka
soyuka / UserIdentitiferNormalizer.php
Last active August 10, 2023 21:49
Me route ApiPlatform
<?php
namespace App\Identifier;
use App\Entity\User;
use Ramsey\Uuid\UuidInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
import { Inject, Injectable, InjectionToken } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Logger, LogglyConfiguration, LOGGLY_CONFIG } from '@partenariat/logger';
@Injectable()
export class AngularLogglyLogger extends Logger {
constructor(http: HttpClient, @Inject(LOGGLY_CONFIG) configuration: LogglyConfiguration) {
super(http, configuration);
}
}
@soyuka
soyuka / full-disk-encryption-arch-uefi.md
Created March 9, 2020 19:46 — forked from huntrar/full-disk-encryption-arch-uefi.md
Arch Linux Full-Disk Encryption Installation Guide [Encrypted Boot, UEFI, NVMe, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS and an encrypted boot partition (GRUB) for UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and self-signed kernel and bootloader.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

Note: The system was installed on an NVMe SSD, substitute /dev/nvme0nX with /dev/sdX or your device as needed.

import React from 'react'
import './close-pixelate.js'
export default class PixelatedImg extends React.Component {
constructor(props) {
super(props)
this.imgRef = React.createRef();
this.parentNode = React.createRef();
this.pixelated = null
}
@soyuka
soyuka / example-1.js
Last active August 24, 2021 16:38
Promise reflect API by bluebird to handle multiple errors in Promise.all
const Promise = require('bluebird')
const lambdas = require('./lambdas.js')
// Ref: https://stackoverflow.com/questions/25817366/bluebird-promise-all-multiple-promises-completed-aggregating-success-and-rejec
Promise.all(lambdas.map(function(promise) {
// On utilise l'API reflect pour inspecter a la main nos promesses voir http://bluebirdjs.com/docs/api/reflect.html
// grace a ca, la promesse réussira toujours
return promise.reflect();
})).each(function(inspection) {
// Ici la lambda (ou promesse) a réussi

Hello,

AbstractObjectNormalizer has a long list of ongoing issues and pull request, we got a talk at Paris Symfony Live with @dunglas @fbourigault and @soyuka on how we want to move forward, here is a resume of our talk and what we would like to achieve for the future:

Current State and Context

At the origin this normalizer was done for API Platform and many other third party libraries / project, in order to have a normalizer that is able to normalize and denormalize any data object (specifically doctrine entities). ObjectNormalizer, PropertyNormalizer and GetSetMethodNormalizer were already existing, but were having slightly different beahvior, that's why two abstract class were created AbstractNormalizer and AbstractObjectNormalizer

Over time, lot of missing features in the ObjectNormalizer were added on both the AbstractObjectNormalizer and the AbstractNormalizer as we needed the same features there.