Skip to content

Instantly share code, notes, and snippets.

@MatthieuScarset
MatthieuScarset / MyCustomForm.php
Last active November 11, 2023 20:24
Drupal - Autosubmit exposed form in JS
<?php
namespace Drupal\mymodule\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a custom form.
*/
@wesbos
wesbos / nuke-bot-tags.js
Created November 29, 2022 19:48
grease monkey script to remove bot tags
// ==UserScript==
// @name Remove Bot Tags
// @version 1
// @grant none
// ==/UserScript==
function nukeEm() {
console.log('Nuke em!');
Array.from(document.querySelectorAll('a[href*="SaveTo"], a[href*="memdotai"]'))
.map(link => {
@gaearon
gaearon / minesweeper.html
Last active October 9, 2023 12:15
minesweeper (incomplete/simplfied). stream: https://www.youtube.com/watch?v=CL01_m50TYY
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="canvas"></div>
<button id="restart">Restart</button>
<script src="minesweeper.js"></script>
<style>
* {
@mglaman
mglaman / bootstrap.php
Created December 24, 2021 19:52
in memory bootstrapped Drupal
<?php declare(strict_types=1);
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
return;
}
$autoloader = require __DIR__ . '/vendor/autoload.php';
@bagder
bagder / h3-server-howto.md
Last active March 10, 2024 21:13
Setup an HTTP/3 test server

Setup a local HTTP/3 test server

... to toy with and run curl against it.

This is not advice on how to run anything in production. This is for development and experimenting.

Preqreqs

An existing local HTTP/1.1 server that hosts files. Preferably also a few huge ones.

@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active May 4, 2024 11:25
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

#!/bin/bash
# This script will download the contents of a GitHub repo
# and place them in a local directory.
#
# Usage:
# download-repo.sh <repo> <output-path> <nested-path> <branch-name>
#
# Example:
# download-repo.sh wattenberger/kumiko ./kumiko-assets master public/assets
# Completely flush redis, old stuff is no longer relevant and wastes space, avoids any
# old state to influence update functions.
./vendor/bin/drush ev "\Drupal::service('redis.factory')->getClient()->flushAll()"
# Check if there are any updates to run.
if [ -n "$(./vendor/bin/drush updbst --format=list 2>/dev/null)" ]; then
# If so, then drush updb includes a drush cr, but separately clear css/js cache
# because due to memory cache backend during updates, it does not invalidate things properly.
./vendor/bin/drush updb -y
./vendor/bin/drush cc css-js
else
@socketwench
socketwench / yourtheme.theme
Created November 9, 2020 04:37
Drupal 8: Add view_mode to block templates, add view mode to template suggestions.
/**
* Implements hook_preprocess_HOOK().
*/
function yourtheme_preprocess_block(&$variables) {
$content = $variables['elements']['content'];
if (isset($content['#block_content']) && $content['#block_content'] instanceof BlockContentInterface) {
$variables['view_mode'] = $content['#view_mode'];
}
}
@duffney
duffney / becomeansible-2-10-dockerfile.md
Last active October 23, 2020 02:30
Dockerfile and supporting links for Ansible 2.10 for become Ansible

Dockerfile

FROM centos:centos7
COPY requirements-azure /tmp
RUN yum check-update; \
yum install -y gcc libffi-devel python3 epel-release; \
yum install -y openssh-clients; \
curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo; \
yum install -y powershell; \