Skip to content

Instantly share code, notes, and snippets.

@soyuka
soyuka / OperationPathResolver.php
Created May 15, 2018 13:24
Workflow bridge for api platform
<?php
declare(strict_types=1);
namespace ApiPlatform\Workflow\PathResolver;
use ApiPlatform\Core\PathResolver\OperationPathResolverInterface;
final class OperationPathResolver implements OperationPathResolverInterface
{
@soyuka
soyuka / components.php
Created January 17, 2024 21:30
components dependencies php
<?php
namespace Components;
use Symfony\Component\Finder\Finder;
$loader = require './vendor/autoload.php';
$namespace = 'ApiPlatform';
$prefix = 'api-platform';
$lnamespace = strlen($namespace);
@soyuka
soyuka / nodistraction.lua
Created October 9, 2023 12:53
No distraction mode neovim
local NoDistraction = { enabled = 0 }
NoDistraction.enable = function()
NoDistraction.enabled = 1
vim.cmd([[
set noshowmode
set noruler
set laststatus=0
set noshowcmd
set nonumber
@soyuka
soyuka / HtmlToBBCode.js
Created August 8, 2013 11:50
Html To BBCode javascript function
//Adapted from http://skeena.net/htmltobb/
var htmlToBBCode = function(html) {
html = html.replace(/<pre(.*?)>(.*?)<\/pre>/gmi, "[code]$2[/code]");
html = html.replace(/<h[1-7](.*?)>(.*?)<\/h[1-7]>/, "\n[h]$2[/h]\n");
//paragraph handling:
//- if a paragraph opens on the same line as another one closes, insert an extra blank line
@soyuka
soyuka / filter.php
Created September 14, 2023 13:54
Guide for complex doctrine filter + api platform by @vincentchalamon
<?php
// ---
// slug: use-doctrine-orm-filters
// name: Use Doctrine Filters
// position: 14
// executable: true
// ---
// Doctrine ORM features [a filter system](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/filters.html) that allows the developer to add SQL to the conditional clauses of queries, regardless of the place where the SQL is generated (e.g. from a DQL query, or by loading associated entities).
//
@soyuka
soyuka / IriConverter.php
Created September 6, 2018 10:19
Override IriConverter and allow an ApiResource to not have any item route associated with it.
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@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;
@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
{
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 / it.php
Created October 27, 2022 10:20
it perf test
<?php
namespace Soyuka\Marsh\Tests;
$a = [];
for ($i=0; $i < 10000; $i++) {
$o = new \stdClass();
$o->i = $i;
$a[] = $o;