Skip to content

Instantly share code, notes, and snippets.


Patrick Allaert patrickallaert

View GitHub Profile
patrickallaert /
Last active Sep 16, 2020
Integrate Phan in PHPStom


  1. Install Phan in your project using Composer, it should create the script vendor/bin/phan, otherwise install it the way you want and hack the run-phan script.
  2. Install script run-phan (see at the bottom of this page) on your system (I decided to put it at /usr/local/bin/run-phan).
  3. In PHPStorm, go in Settings > Tools > External Tools, add a new tool and provide the parameters:
    • Program: /usr/local/bin/run-phan
    • Working directory: $ProjectFileDir$
    • Check "Open console for tool output"
    • Output filters: $FILE_PATH$:$LINE$
  4. You can now use it from Tools > External Tools > Phan (or assign it a shortcut)
patrickallaert / example.html
Created Feb 12, 2020
Example of image gallery
View example.html
<section class="images">
<a href="/image/a">
<source srcset="/thumbnail/a.webp" type="image/webp"/>
<source srcset="/thumbnail/a.jpg" type="image/jpeg"/>
<img alt="" src="/thumbnail/a.jpg"/>
<a href="/image/b">
View gist:c08c76f2718ed8856af43587fc57a201
Installed Packages
acl.x86_64 2.2.53-1.el8 @ubi-8-baseos
apr.x86_64 1.6.3-9.el8 @ubi-8-appstream
apr-util.x86_64 1.6.1-6.el8 @ubi-8-appstream
apr-util-bdb.x86_64 1.6.1-6.el8 @ubi-8-appstream
apr-util-openssl.x86_64 1.6.1-6.el8 @ubi-8-appstream
audit-libs.x86_64 3.0-0.10.20180831git0047a6c.el8 @System
basesystem.noarch 11-5.el8 @System
bash.x86_64 4.4.19-7.el8 @System
brotli.x86_64 1.0.6-1.el8 @System
patrickallaert / script.js
Created Feb 25, 2019
defer image loading
View script.js
document.addEventListener("DOMContentLoaded", function() {
const srcDeferAttribute = "data-defer";
const srcBackingAttribute = "data-deferred";
document.querySelectorAll("*[" + srcDeferAttribute + "]").forEach(function(lazyImage) {
if (!lazyImage.complete) {
lazyImage.setAttribute(srcBackingAttribute, lazyImage.getAttribute("src"));
lazyImage.setAttribute("src", "data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=");
View tweets.php
return [
"name" => "Princess Leia",
"account" => "Princess_Leia",
"tweets" => [],
"name" => "Luke Skywalker",
patrickallaert / Xsetup
Created Nov 2, 2017
SDDM black screen gentoo
View Xsetup
# /usr/share/sddm/scripts/Xsetup
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --output eDP-1-1 --mode 2880x1620
View test.c
#include <bsd/string.h>
int main() {
char error[100];
char test[10];
test[0] = '\0';
strlcpy(error, test, sizeof(error));
return 0;
View sample.php
if (!is_callable($callable)) {
throw new \InvalidArgumentException(
'The controller for URI "' . $request->getPathInfo() . '" is not callable. '.
View sprintf_vs_without.php
$distinct = "DISTINCT"; // or empty
$columns = "a, b, c"; // columns
$table = "thetable"; // table to retrieve content from
$delete = false; // Fetch records marked deleted
$conditions = ""; // Series of conditions
$orderCol = "a"; // Order by
$orderDir = "ASC"; // Order by ASC/DESC
$limit = ""; // Optional limit number
View poll.php
// Performance appart, what is the most *READABLE* code to generate a simple error string?
$errorMessage = "Rule execution failed: " . $e->getMessage(); // Choice 1
$errorMessage = "Rule execution failed: {$e->getMessage()}"; // Choice 2
$errorMessage = sprintf('Rule execution failed: %s', $e->getMessage()); // Choice 3