Skip to content

Instantly share code, notes, and snippets.

View guillemcanal's full-sized avatar

Guillem CANAL guillemcanal

View GitHub Profile
self: super:
{
php = super.php82.buildEnv {
extensions = ({ enabled, all }: enabled ++ (
with all; [
xdebug
redis
amqp
])
);
!function(){"use sctrict";function n(n){return/^\s*$/.test(n)}window.theredoc=function(t,...e){const c=function(t){const e=n(t[0]),c=n(t[t.length-1]);return e||c?t.slice(e?1:0,c?t.length-1:t.length):t}(function(n,t){let e="";return n.forEach((n,c)=>{e+=n+(t[c]||"")}),e}(t,e).split("\n"));return function(n,t){const e=new RegExp(`^ {${t}}`);return n.map(n=>e.test(n)?n.replace(e,""):n)}(c,function(n){let t=null;return n.forEach(n=>{const e=n.search(/[^ ]/);-1!==e&&(null===t||e<t)&&(t=e)}),t}(c)).join("\n")}}();
@guillemcanal
guillemcanal / script.js
Created May 15, 2022 15:49
Livechart.me Pimped List
// ==UserScript==
// @name Pimp My List
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Pin unwatched animes on top of the list, remember filters, add priorities to "considered" animes
// @author Guillem CANAL
// @match https://www.livechart.me/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=livechart.me
// @grant none
// ==/UserScript==
@guillemcanal
guillemcanal / xdebug-handler-nix-boom.php
Last active March 13, 2022 15:50
Scripts using the XdebugHandler componant will load PHP extensions twice on a Nix environment
<?php
require __DIR__ . '/vendor/autoload.php';
// Most PHP CLI tools run this snippet to disable Xdebug at runtime
use Composer\XdebugHandler\XdebugHandler;
$xdebug = new XdebugHandler('myCliApp');
$xdebug->setPersistent();
$xdebug->check();
<?php
print join("\n", array_map(fn(string $name) => $name.':'.(new ReflectionExtension($name))->getVersion(), get_loaded_extensions()));
@guillemcanal
guillemcanal / given-names-in-france-in-2020.json
Last active July 31, 2021 16:28
List of given names in 2020 in France (source: INSEE)
[
{
"number": 3,
"name": "AADAM"
},
{
"number": 5,
"name": "AAHIL"
},
{
@guillemcanal
guillemcanal / disney-movies.sparql
Created June 24, 2021 15:27
Extract Disney/Pixar movies from Wikidata
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wds: <http://www.wikidata.org/entity/statement/>
PREFIX wdv: <http://www.wikidata.org/value/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
@guillemcanal
guillemcanal / dockerd.sh
Created March 7, 2021 15:19
Ghetto dockerd startup script example
#!/usr/bin/env sh
set -e
main() {
case $1 in
start)
pgrep dockerd || sudo nohup /usr/bin/dockerd \
--tlsverify \
--tlscacert=/home/user/.docker/ca.pem \
@guillemcanal
guillemcanal / clear-github-notifications.js
Last active May 6, 2021 13:31
Github Notifications Page Cleanup
/**
* Clean the Github's Notification Page
*
* @see https://github.com/notifications
*
* @param {String} type Either "all", "merged", "closed", "draft" or "closed-issues"
*/
const clearGithubNotifications = type => {
// @TODO Handle notifications list refresh (when the user have multiple pages of notifications)
const PULL_REQUEST_MERGED = ".octicon-git-merge";
<?php
interface TimeProvider
{
public function now(): \DateTimeImmutable;
}
class SystemTime implements TimeProvider
{
public function now(): \DateTimeImmutable