Skip to content

Instantly share code, notes, and snippets.

View joanfabregat's full-sized avatar

Joan Fabrégat joanfabregat

View GitHub Profile
@joanfabregat
joanfabregat / install-yarn-debian-11.sh
Created April 4, 2023 11:30
Installer Yarn sur Debian 11 Bullseye
apt-get update
apt-get install -y gnupg
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update
apt-get install -y yarn
@joanfabregat
joanfabregat / regexp-metacharacters.md
Created April 4, 2023 11:30
Regexp metacharacters
. Find a single character, except newline or line terminator
\w Find a word character
\W Find a non-word character
\d Find a digit
\D Find a non-digit character
\s Find a whitespace character
\S Find a non-whitespace character
\b Find a match at the beginning/end of a word, beginning like this: \bHI, end like this: HI\b
\B Find a match, but not at the beginning/end of a word
@joanfabregat
joanfabregat / install-php-rar.sh
Last active March 31, 2023 10:52
Install PHP RAR extension (for PHP 8.1 / 8.2)
# source: https://github.com/cataphract/php-rar/issues/17#issuecomment-1001826233
git clone https://hub.fastgit.org/cataphract/php-rar.git
cd php-rar
phpize
./configure
make
make install
cd ../
rm -rf php-rar
@joanfabregat
joanfabregat / vue-suspense-with-router-view.vue
Created March 30, 2023 15:32
Using suspense with router-view
<router-view v-slot="{ Component }">
<suspense timeout="0">
<template #default>
<component :is="Component" :key="$route.path"></component>
</template>
<template #fallback>
<div>Loading...</div>
</template>
</suspense>
</router-view>
@joanfabregat
joanfabregat / doctrine-entity-get-missing-relation.php
Last active March 24, 2023 17:02
Get Doctrine Entity missing relation
<?php
/**
* @noinspection PhpRedundantCatchClauseInspection
* @noinspection PhpUnusedLocalVariableInspection
*/
public function getUser(): ?User
{
try {
$this->user?->getId();
return $this->user;
@joanfabregat
joanfabregat / Dockerfile
Created March 17, 2023 09:14
Wekpack Docker build for a Symfony app
##################################################################################################################
# Public assets (JS, Vue, images, etc.)
##################################################################################################################
FROM node:18-bullseye AS webpack-build
# configuring Yarn
RUN mkdir -p /app/public/build
WORKDIR /app
COPY yarn.lock .
COPY package.json .
@joanfabregat
joanfabregat / favicon-meta.html
Created February 25, 2023 12:40
Meta tag pour l'intégration d'un favicon
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="icon" type="image/x-icon" href="/favicon.ico">
@joanfabregat
joanfabregat / hour-minutes.php
Created February 25, 2023 12:36
Heures et minutes en PHP
function getHoursAndMinutes(int $seconds): string
{
return sprintf(
"%dh%02d",
(int)floor($seconds / 3600),
($seconds / 60) % 60
);
}
@joanfabregat
joanfabregat / nginx-robots.conf
Created February 25, 2023 12:33
Servir robot.txt avec Nginx
location /robots.txt {
return 200 "User-agent: *\\nDisallow: /";
access_log off;
}
@joanfabregat
joanfabregat / git-renamed-tag.sh
Created February 25, 2023 12:24
Renommer un tag Git
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags