Skip to content

Instantly share code, notes, and snippets.

@Kingdutch
Kingdutch / EXPAND.md
Created May 15, 2025 21:10
Drupal Core documentation summarised for easy consumption by LLMs

Documentation Expansion Strategy for Drupal Core AI Documentation

You are an expert in both Drupal core architecture and technical documentation. Your task is to systematically expand the AI-optimized documentation for Drupal core, filling gaps in coverage while maintaining the established format and depth.

Documentation Assessment Process

  1. Inventory Current Coverage
    • Analyze existing .ai-docs files to understand what's already documented
    • Map the documented components to the Drupal core architecture
  • Identify major architectural areas without documentation
@Kingdutch
Kingdutch / trait.rs
Created March 16, 2025 12:36
Allow `.context` to be called on a future that returns result without awaiting.
use std::error::Error;
use std::result::{Result as StdResult};
use anyhow::{Context, Result};
trait FutureExt<O> {
async fn context(self, ctx: &'static str) -> Result<O, anyhow::Error>;
}
impl<T, O, E> FutureExt<O> for T
where
@Kingdutch
Kingdutch / type-resolver-interface.patch
Created June 17, 2021 15:46
Patch to add interface to GraphQL Type decorator
From 27a47d83645fccc52fefe98c2e246e07ac78e84b Mon Sep 17 00:00:00 2001
From: Alexander Varwijk <[email protected]>
Date: Thu, 17 Jun 2021 17:40:10 +0200
Subject: [PATCH] Provide DecoratableTypeResolverInterface
The interface allows alternative but compatible decoratable type
resolvers to be created. It also provides an upgrade path for projects
that were already using the pattern.
---
src/GraphQL/DecoratableTypeResolver.php | 34 ++--------
@Kingdutch
Kingdutch / analysis.js
Created April 18, 2020 22:29
A dive into react-sizeme and what may be the cause of the render issues
// Relevant render code from the SizeMe component in react-sizeme
render() {
const { SizeAware } = this
const render = this.props.children || this.props.render
return (
<SizeAware onSize={this.onSize}>
// ! Here it calls the function that you provide. React doesn't know anything about this,
// it only know about the output.
{render({ size: this.state.size })}
</SizeAware>
@Kingdutch
Kingdutch / bsconfig.json
Created April 6, 2020 19:29
Most simple BSB + Webpack config possible
{
"name": "@open-social/components",
"reason": {
"react-jsx": 3
},
"bsc-flags": ["-bs-super-errors"],
"sources": [
{
"dir": "src",
"subdirs": true
@Kingdutch
Kingdutch / - Multilingualism Makes Better Programmers.md
Last active October 27, 2019 15:25
Code Snippets for Drupaljam:XL 2019 and DrupalCon Amsterdam 2019

Multilingualism makes better programmers

The below Gist contains the code samples that I've used in my talk "Multilingualism makes better programmers".

@Kingdutch
Kingdutch / useBrewManager.js
Created March 15, 2019 15:07
A custom hook to update state using an interval and trigger a callback after a certain time.
import { useReducer, useCallback, useState } from "react";
import useInterval from "./useInterval";
const initialState = {
brewing: false,
tea: null,
brewTime: 0,
brewStart: 0,
elapsed: 0
};
@Kingdutch
Kingdutch / package.json
Created February 28, 2019 07:28
Post create-react-app package.json with Prettier without ejecting
{
"name": "tea-companion",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-scripts": "2.1.5",
"styled-components": "^4.1.3"
},
@Kingdutch
Kingdutch / Colors.js
Last active February 22, 2019 20:42
This gist contains some react components for displaying color palettes in a visually pleasing way. It uses React (from create-react-app) with styled components. The display is inspired by the Refactoring UI book. The colors.js file makes it very easy to add/remove/adjust colors and see the results. Simply render the Colors component in your Reac…
// src/components/Colors.js
import React from 'react';
import styled from 'styled-components';
import Swatch from './Swatch';
import colors from '../styles/colors';
const ucfirst = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
@Kingdutch
Kingdutch / example.jsx
Last active September 13, 2018 20:03
This gist has been written on GitHub in the gist editor so it's not working code. However, I hope it conveys the idea.
const cache = require('./shared-cache');
// Using the simple-cache-provider.
const ItemFetcher = createFetcher(/** some fetcher **/);
class ItemList extends React.component {
render() {
// Load all available items.
const items = ItemFetcher.read(cache);
return <p>{this.props.items.join(", ")}</p>;