Skip to content

Instantly share code, notes, and snippets.

View bpolaszek's full-sized avatar

Beno!t POLASZEK bpolaszek

View GitHub Profile
@bpolaszek
bpolaszek / check-environment-variables.php
Last active November 5, 2018 11:15
Check that all environment variables defined in your .env.dist are properly set.
#!/usr/bin/env php
<?php
/**
* Checks that all environment variables are set before deploying.
*
* @author Beno!t POLASZEK - 2018
* @link https://gist.github.com/bpolaszek/559dbc341dec51303fc0dea8162cf735#gistcomment-2747882
*/
@bpolaszek
bpolaszek / API-Platform New Documentation Hierarchy.md
Last active October 7, 2019 13:42
New documentation hierarchy suggestion for Api-Platform 2.x.

API-Platform Documentation

Getting started

1. Introduction

Introduction, concepts, features, other resources

@bpolaszek
bpolaszek / debug-breakpoint.html
Created January 8, 2020 14:54
HTML snippet for breakpoint debugging / Bootstrap 4
<div class="d-inline-block d-sm-none">XS</div>
<div class="d-none d-sm-inline-block d-md-none">SM</div>
<div class="d-none d-md-inline-block d-lg-none">MD</div>
<div class="d-none d-lg-inline-block d-xl-none">LG</div>
<div class="d-none d-xl-inline-block">XL</div>
@bpolaszek
bpolaszek / select-countries.html
Created July 17, 2020 09:13
Vanilla JS snippet to generate a SELECT country list from an API.
<select id="country" name="country">
<option/>
</select>
<script>
(async () => {
const response = await fetch('https://restcountries.eu/rest/v2/all?fields=alpha2Code;name');
const countries = await response.json();
const select = document.getElementById('country');
for (const country of countries) {
const option = document.createElement('option');
@bpolaszek
bpolaszek / ApiClient.php
Created July 26, 2021 10:35
Pest Api-Platform Client
<?php
declare(strict_types=1);
namespace App\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Client;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
@bpolaszek
bpolaszek / tailwind-breakpoint-debug.html
Created September 11, 2021 14:01
Quickly debug your current Tailwind CSS breakpoint
<!-- Temporary breakpoint debugger -->
<span class="sm:hidden">XS</span>
<span class="hidden sm:inline md:hidden">SM</span>
<span class="hidden md:inline lg:hidden">MD</span>
<span class="hidden lg:inline xl:hidden">LG</span>
<span class="hidden xl:inline">XL</span>
<!-- / Temporary breakpoint debugger -->
@bpolaszek
bpolaszek / DebugBreakpoint.vue
Created March 25, 2022 10:09
Tailwind + Vue3 breakpoint debugger
<template>
<div v-if="show" class="absolute inset-0 h-screen w-screen bg-white bg-opacity-75 text-black z-500 flex items-center overflow-hidden">
<div class="mx-auto text-5xl uppercase">{{ currentBreakpoint }}</div>
</div>
</template>
<script setup>
import { refAutoReset, useMediaQuery } from '@vueuse/core';
import { computed, reactive, watch } from 'vue';
SELECT table_schema AS `Database`,
table_name AS `Table`,
FORMAT(table_rows, 'en_US') AS `Rows`,
CONCAT(IF(data_size / POWER(1024, 3) < 1, FORMAT(data_size / POWER(1024, 2), 0),
FORMAT(data_size / POWER(1024, 3), 2)), IF(data_size / POWER(1024, 3) < 1, 'MB', 'GB')) AS `Data`,
CONCAT(IF(index_size / POWER(1024, 3) < 1, FORMAT(index_size / POWER(1024, 2), 0),
FORMAT(index_size / POWER(1024, 3), 2)), IF(index_size / POWER(1024, 3) < 1, 'MB', 'GB')) AS `Indexes`,
CONCAT(IF(total_size / POWER(1024, 3) < 1, FORMAT(total_size / POWER(1024, 2), 0),
FORMAT(total_size / POWER(1024, 3), 2)), IF(total_size / POWER(1024, 3) < 1, 'MB', 'GB')) AS `Total`
FROM (SELECT table_schema,
@bpolaszek
bpolaszek / CleanAssociationsTrait.php
Created September 24, 2015 09:43
Doctrine : Fix ManyToOne relationships when the value in database is 0 instead of NULL
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Event\LifecycleEventArgs;
/**
* Trait CleanAssociationsTrait
*
* This trait is intended to fix the Doctrine ManyToOne relationships when the stored value in database is a 0 instead of NULL.
* Sometimes you plug Doctrine on an existing database without foreign key support.
@bpolaszek
bpolaszek / bootstrap.php
Last active December 19, 2023 19:49
Symfony shortcuts for Pest
<?php
# tests/bootstrap.php
declare(strict_types=1);
namespace App\Test;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Client;
use App\Entity\User;
use App\Kernel;