Skip to content

Instantly share code, notes, and snippets.

@soyuka
soyuka / gist:f52aa1a14f86bdf5c55767f5c686a7ba
Created August 13, 2024 16:08
Use facebook upload api with symfony http client (warning this endpoint is not yet supported by facebook's own endpoints)
$uploadSession = $this->metaClient->request('POST', sprintf('%s/uploads', $this->metaAppId), [
'query' => [
'file_name' => $mediaObject->getFilePath(),
'file_length' => $mediaObject->getContentSize(),
'file_type' => $mediaObject->getMimeType(),
'access_token' => $credential->getAccessToken(),
'appsecret_proof' => $this->secretProof($credential->getAccessToken()),
],
])->toArray();
@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 / 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 / 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;
@soyuka
soyuka / switch_dark_mode.sh
Created September 5, 2022 09:02
Switch theme alacritty
#!/bin/bash
from=$(cat ~/.config/sway/current_scheme)
if [ "$from" = "black" ]; then
from=black
to=white
else
from=white
to=black
@soyuka
soyuka / stub.php
Created April 4, 2022 17:33
Stubs api platform
<?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 / wow.ts
Created January 5, 2022 15:59
component dynamic angular
@ViewChild('vc', {read: ViewContainerRef}) vc: ViewContainerRef;
constructor(private _compiler: Compiler,
private _injector: Injector,
private _m: NgModuleRef<any>) {
}
ngAfterViewInit() {
const template = '<span>generated on the fly: {{name}}</span>';
@soyuka
soyuka / DebugResourceCommand.php
Created May 8, 2021 10:50
Debug command api platform resource collection
<?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 / Caddyfile
Created April 6, 2021 09:39
Postgrest JSON-LD support
{
debug
}
localhost
file_server
@resource path_regexp resource ^/api/([a-z_]+)/([a-z0-9-]+)$
@resources path_regexp resources ^/api/([a-z_]+)$