Skip to content

Instantly share code, notes, and snippets.

View alexander-schranz's full-sized avatar

Alexander Schranz alexander-schranz

View GitHub Profile
@alexander-schranz
alexander-schranz / deploy.php
Last active January 26, 2023 17:36
Deployer deploy.php without Git Repository
<?php
namespace Deployer;
use Deployer\Task\GroupTask;
require 'recipe/sulu.php';
require 'contrib/rsync.php';
host('example.org')
@alexander-schranz
alexander-schranz / detect.sh
Last active January 5, 2023 17:50
Detect Symfony Components used inside your project to migrate symfony/symfony to specific components
# copy this into your shell/terminal:
php -r '
require_once("vendor/autoload.php");
use Symfony\\Component\\Finder\\Finder;
$symfonyComponents = [];
$useFinder = new Finder();
@alexander-schranz
alexander-schranz / composer-info-date.php
Created December 16, 2022 15:55
Get Composer Vendor Package Version date
<?php
// requires `rm -rf vendor && composer install --prefer-source` as it works via git tag
$dir = new DirectoryIterator(__DIR__ . "/vendor");
$list = [];
$biggestLength = 0;
foreach ($dir as $fileinfo) {
if (in_array($fileinfo->getFilename(), [".", ".."])) {
@alexander-schranz
alexander-schranz / example1.scss
Last active October 11, 2022 15:07
Example Font Size Settings
$font-family-headline: 'Lyon';
$font-family-base: 'Source Sans Pro';
$font-settings: (
mobile-headline-l: (
font-family: $font-family-headline,
font-size: 34px,
line-height: 38px,
font-weight: $font-weight-bold,
),
@alexander-schranz
alexander-schranz / expander_controller.ts
Last active December 11, 2023 15:06
Accessibility aware expander component to hide and show a container
import { Controller } from '@hotwired/stimulus';
/**
* A stimulus controller to handle aria-expanded and aria-controls correctly:
* See also:
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded
* https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls
*
* It is specially build for dialog tags or tags hidden via hidden attribute.
* It is not considered for elements behave differently in a responsive sites,
@alexander-schranz
alexander-schranz / _composer.json
Last active August 13, 2022 23:24
PHP instead of Yaml Skeleton files
{
"extra": {
"symfony": {
"allow-contrib": false,
"require": "6.1.*",
"endpoint": [
"https://raw.githubusercontent.com/alexander-schranz/symfony-recipes-php/flex/main/index.json",
"https://raw.githubusercontent.com/alexander-schranz/symfony-recipes-php-contrib/flex/main/index.json",
"flex://defaults"
]
@alexander-schranz
alexander-schranz / rebase.sh
Last active August 4, 2022 08:26
Rebase a pull request to a previous version
# clone repository
git clone git@github.com:your-name/sulu.git
cd sulu
# checkout your branch
git fetch origin
git checkout your-branch
# add target remote
git remote add sulu git@github.com:sulu/sulu.git
@alexander-schranz
alexander-schranz / package.json
Last active August 1, 2022 20:23
Recommendation for a general package.json configuration to provide file types for different bundlers
{
"name": "mypackage",
"dependencies": {},
"devDependencies": {},
"files": [
[
"match": "/src/**/*.ts",
"type": "TypeScript",
"version": "4.8",
"options": {
@alexander-schranz
alexander-schranz / alternative-sql-keywords.md
Last active July 22, 2022 10:43
Alternative to SQL reserved Keywords

Alternative to reserved SQL Keywords

Keyword Alternatives
from start, startAt
count amount, total, (sum?)
limit maximum, limitation, (max?)
 key key_value
 default default_value, fallback
@alexander-schranz
alexander-schranz / BreadcrumbTwigExtension.php
Last active July 11, 2022 17:02
Navigation, Breadcrumb and Tab Groups via Static Symfony Route Options
<?php
declare(strict_types=1);
namespace App\Extranet\Infrastructure\Twig;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouterInterface;