Skip to content

Instantly share code, notes, and snippets.

@soyuka
soyuka / switch_dark_mode.sh
Created Sep 5, 2022
Switch theme alacritty
View switch_dark_mode.sh
#!/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 Apr 4, 2022
Stubs api platform
View stub.php
<?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 Jan 5, 2022
component dynamic angular
View wow.ts
@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
Debug command api platform resource collection
View DebugResourceCommand.php
<?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 Apr 6, 2021
Postgrest JSON-LD support
View Caddyfile
{
debug
}
localhost
file_server
@resource path_regexp resource ^/api/([a-z_]+)/([a-z0-9-]+)$
@resources path_regexp resources ^/api/([a-z_]+)$
@soyuka
soyuka / Makefile
Created Mar 3, 2021 — forked from Pierstoval/confirm.Makefile
"confirm" action for your Makefile
View Makefile
# To use the "confirm" target inside another target,
# use the " if $(MAKE) -s confirm ; " syntax.
mycommand:
@if $(MAKE) -s confirm ; then \
execute_your_command_here ; \
fi
.PHONY: mycommand
# The CI environment variable can be set to a non-empty string,
@soyuka
soyuka / PropertyMetadataFactory.php
Created Feb 18, 2021
API Platform use the Model namespace for the API and the Entity namespace for doctrine
View PropertyMetadataFactory.php
<?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 Dec 14, 2020
API Platform bootstrap
View index.php
<?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 Sep 11, 2020
Stresstest event source
View stresstest.js
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 Jun 12, 2020
Patch a composer vendor on the fly
View composer.json
"scripts": {
"post-update-cmd": "cd vendor/symfony/serializer && cat ../../../serializer.patch | patch"
}