Skip to content

Instantly share code, notes, and snippets.

View bpolaszek's full-sized avatar

Beno!t POLASZEK bpolaszek

View GitHub Profile
@bpolaszek
bpolaszek / ikea-somrig-z2m.yaml
Last active January 8, 2024 12:35 — forked from amorfinvdev/somrig.yaml
Ikea Somrig Remote Blueprint (Z2M)
blueprint:
name: IKEA Somrig Controls (Z2M)
description: "## Control anything with IKEA Somrig Dimmer remote (v1.0)
Only for use with Zigbee2MQTT ([MQTT](https://www.home-assistant.io/integrations/mqtt)
+ [Z2M addon](https://www.zigbee2mqtt.io/guide/installation/03_ha_addon.html)).
Adapted from https://gist.github.com/damru/b2c1c780ffb0ddc084952eb89db9573a
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 / 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';
@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 / 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 / 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 / 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;
@bpolaszek
bpolaszek / mercure-provision.sh
Last active April 9, 2024 20:27
Setup Mercure as a service on Ubuntu 20.04
MERCURE_URL=${MERCURE_URL:=https://github.com/dunglas/mercure/releases/download/v0.10.4/mercure_0.10.4_Linux_x86_64.tar.gz}
JWT_KEY=${JWT_KEY:=!ChangeMe!}
MERCURE_FILE=${MERCURE_URL##*/}
# Settings perms
echo "Creating mercure user..."
groupadd --system mercure
useradd --system \
--gid mercure \
--create-home \
@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 / 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