Skip to content

Instantly share code, notes, and snippets.

View superbiche's full-sized avatar
🕹️
Working from everywhere

Michel Tomas superbiche

🕹️
Working from everywhere
View GitHub Profile
@superbiche
superbiche / 196-arrayaccess-type-compatibility.patch
Last active March 27, 2022 19:35
Sendinblue PHP SDK v3 - PHP 8.1 GetLists ArrayAccess fix
diff --git a/lib/Model/AbTestCampaignResult.php b/lib/Model/AbTestCampaignResult.php
index 8d8e1cb..a605944 100644
--- a/lib/Model/AbTestCampaignResult.php
+++ b/lib/Model/AbTestCampaignResult.php
@@ -200,9 +200,9 @@ class AbTestCampaignResult implements ModelInterface, ArrayAccess
const WINNING_VERSION_B = 'B';
const WINNING_CRITERIA_OPEN = 'Open';
const WINNING_CRITERIA_CLICK = 'Click';
-
@superbiche
superbiche / wp-autosave-not-draft.php
Created November 26, 2015 15:40
Wordpress save_post action, that doesn't fire when autosaving.
add_action('save_post', 'my_post_saved');
function my_post_saved($post_id, $post) {
if (isset($post->post_status) && 'auto-draft' == $post->post_status) {
return;
}
// Autosave, do nothing
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
@superbiche
superbiche / insert-before-after-key.php
Created October 8, 2015 16:17
Insert a value before/after a specific key in an associative array.
/*
* Inserts a new key/value before the key in the array.
*
* @param $key
* The key to insert before.
* @param $array
* An array to insert in to.
* @param $new_key
@superbiche
superbiche / install-composer.sh
Created February 5, 2022 19:46
Install Composer programmatically
#!/bin/sh
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
diff --git a/block_breakpoint.module b/block_breakpoint.module
index b3d0f4b..1a6d711 100644
--- a/block_breakpoint.module
+++ b/block_breakpoint.module
@@ -51,7 +51,7 @@ function block_breakpoint_form_layout_builder_configure_block_alter(&$form, Form
*/
function block_breakpoint_preprocess_layout(&$variables) {
$layout = $variables['layout'] ?? NULL;
- if ($regions = $layout->getRegionNames()) {
+ if (is_object($layout) && is_callable('getRegionNames', $layout) && $regions = $layout->getRegionNames()) {
diff --git a/composer.json b/composer.json
index 7de7360..ff39c55 100644
--- a/composer.json
+++ b/composer.json
@@ -17,6 +17,6 @@
},
"license": "GPL-2.0+",
"require": {
- "php": "^7.1"
+ "php": "^7.1|^8.0"
@superbiche
superbiche / drupal-block-breakpoint.patch
Last active August 18, 2021 12:20
Drupal block_breakpoint I'm working on
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9f11b75
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea/
diff --git a/config/schema/block_breakpoint.schema.yml b/config/schema/block_breakpoint.schema.yml
index 9e94a14..8bf3b08 100644
--- a/config/schema/block_breakpoint.schema.yml
@superbiche
superbiche / remove-firefox-sound-tab.scss
Created August 24, 2016 14:08
Disable sound indicator in Firefox tabs Useful if video is muted but the indicator is still visible (PLEASE keep this indicator if you play sound)
// Only pinned tabs
.tabbrowser-tab[pinned] :-moz-any(.tab-icon-overlay[soundplaying]) {
display: none;
}
// Any tab
.tabbrowser-tab :-moz-any(.tab-icon-sound,.tab-icon-overlay[muted]) {
display: none;
}
@superbiche
superbiche / gist:e85cd613ec4d59ef6223
Created October 10, 2015 17:11
VLC plugin - delete currently playing file
--[[
INSTALLATION (create directories if they don't exist):
- put the file in the VLC subdir /lua/extensions, by default:
* Linux (all users): /usr/share/vlc/lua/extensions/
* Linux (current user): ~/.local/share/vlc/lua/extensions/
* Mac OS X (all users): /Applications/VLC.app/Contents/MacOS/share/lua/extensions/
* Windows: not supported - getting permission error on delete...
- Restart VLC.
]]--
@superbiche
superbiche / cache-warmer.py
Last active June 21, 2020 00:17 — forked from hn-support/cache-warmer.py
A threaded cache warmer in python
#!/usr/bin/env python
"""
Warm the caches of your website by crawling each page defined in sitemap.xml (can use a local file or an URL).
To use, download this file and make it executable. Then run:
./cache-warmer.py --threads 4 --url http://example.com/sitemap.xml -v
"""
import argparse
import multiprocessing.pool as mpool
import os.path
import re