Skip to content

Instantly share code, notes, and snippets.

View meduzen's full-sized avatar
🌍
<body> in Belgium, <head> worldwide.

Mehdi meduzen

🌍
<body> in Belgium, <head> worldwide.
View GitHub Profile
@meduzen
meduzen / laravel-localization-fix-localizedUrlWithSlugParameter.md
Last active April 1, 2024 18:20
A helper to allow named route with slug (named-route/{slug}) translation in mcamara/laravel-localization
/**
 * Localize current URL having a {parameter}.
 *
 * Awaiting a fix to the laravel-localization package
 * this helper will translate any translated route
 * that accept a mandatory slug, but no ?query.
 *
 * GitHub issue: https://github.com/mcamara/laravel-localization/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20getLocalizedURL
 *
const SW_VERSION = '1.2.3' // update it when the app changes: invalidates `resourcesToCache`
const resourcesCacheKey = `cache-v${SW_VERSION}`
const microfrontendCacheKey = `mfe` // not sure versioning is needed
const resourcesToCache = [
'/',
'site.webmanifest',
'css/app.css',
@meduzen
meduzen / timer.js
Last active November 24, 2023 12:56
Approach for using setInterval / setTimeout in a vue-x store
const MILLISECONDS_PER_MINUTES = 1000 * 60;
const state = {
now: (new Date()),
intervalTimer: null,
};
const mutations = {
now(state) {
state.now = new Date();
@meduzen
meduzen / ViewServiceProvider.php
Last active November 21, 2023 19:41
Laravel Blade @Currency, @usd and @Eur directives
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class ViewServiceProvider extends ServiceProvider
{
/**
@meduzen
meduzen / bpost-tracking.js
Last active October 20, 2023 08:30
Run this in the browser console on https://track.bpost.cloud ; don’t forget to update the first 3 lines.
const trackingCode = '324567890'
const postCode = 1000
const language = 'EN' // 'FR', 'NL', 'EN'
let status = null
let deliveryWindow = null
setInterval(() => {
fetch('https://track.bpost.cloud/track/items?itemIdentifier=' + trackingCode + '&postalCode=' + postCode)
.then(res => {
@meduzen
meduzen / list.md
Last active December 24, 2022 21:25
Alternatives to Google Analytics
@meduzen
meduzen / README.md
Last active July 26, 2021 11:00
Get all files path in a PR, excluding the files marked as viewed or deleted
  1. Open your dev tools.
  2. Paste this in the console:
Array
  .from(document.querySelectorAll('.js-file'))
  .filter(el => !('fileUserViewed' in el.dataset) && el.dataset.fileDeleted == 'false')
  .map(el => el.querySelector('.file-header').dataset.path)
/* Answer to https://twitter.com/stevepiron/status/900732215415508994
*
* How can I not show the :focus style when clicking an element, but keep it for keyboard navigation?
*/
// hover (mouse only)
:hover {}
// click (mouse only)
:active:hover {}
@meduzen
meduzen / always-trim-custom-properties.html
Last active July 11, 2021 13:34
CSS custom properties (CSS variables) stuff
<html>
<head>
<style>
:root {
/* Like me, you probably add a space between the semicolon and the value.
👇 */
--bg: hsl(0 0% 100%);
}
@meduzen
meduzen / voice-over-ecriture-dite-inclusive.html
Last active March 22, 2021 19:34
(For French person only)
<!-- « un neu concepteurice », says Voice Over -->
<p>Test 1 : nous recherchons un•e concepteur•rice & rédacteur•rice francophone.</p>
<!-- « une concepteurice », says Voice Over `(content: '•'` is ignored) -->
<p>Test 2 : nous recherchons un<span class="content-middot"></span>e concepteur<span class="content-middot"></span>rice & rédacteur<span class="content-middot"></span>rice francophone.</p>
<!-- `alt is ignored by macOS Voice Over -->
<p>Test 3 : nous recherchons <span alt="un concepteur et rédacteur, ou une conceptrice et rédactrice">un•e concepteur•rice & rédacteur•rice</span> francophone.</p>
<!-- `aria-label` or `aria-labelledby` is ignored by macOS Voice Over -->