Skip to content

Instantly share code, notes, and snippets.

@steffenr
steffenr / ai-model-credits.md
Created September 23, 2026 10:11
Free AI Model Credits — a hand-checked list of working sign-up offers

Free AI Model Credits — a hand-checked list of working sign-up offers

Most model gateways will front you credit just for making an account — no card, no commitment. It is the cheapest way to find out how a model actually behaves on your prompts before you spend a cent. The problem is that half the offers you find online are dead, capped to a trial you can't use for real work, or quietly gated behind a card.

This is a short list of the ones that currently pay out and work with a normal coding tool (Claude Code, Codex, Cursor, opencode, oh-my-pi, …). Every entry is an Anthropic- or OpenAI-compatible endpoint: point your client at the base URL, paste the key, burn the

@steffenr
steffenr / my_module.post_update.php
Last active July 3, 2026 10:23
Updating text field length with existing data in Drupal 11
<?php
/**
* @file
* Post update functions for my_module module.
*/
declare(strict_types=1);
use Drupal\Core\Database\Database;
@steffenr
steffenr / my_module.install.php
Last active April 21, 2026 08:18
Fix mismatched rabbit_hole__settings field storage definitions.
<?php
/**
* Fix mismatched rabbit_hole__settings field storage definitions.
*/
function my_module_update_9001():void {
$updates = \Drupal::entityDefinitionUpdateManager();
$field_manager = \Drupal::service('entity_field.manager');
$entity_types = ['node', 'taxonomy_term'];
@steffenr
steffenr / po_to_csv.sh
Created December 8, 2023 07:46
Convert .po to .csv
#!/bin/bash
# Check if the required command-line argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <po_file>"
exit 1
fi
po_file="$1"
csv_file="${po_file%.po}.csv"
@steffenr
steffenr / mymodule.libraries.yml
Created August 12, 2016 11:40
Attach a CSS or JS library to a View in Drupal 8
custom_view:
css:
component:
css/custom_view.css: {}
@steffenr
steffenr / ip_adapter_face_sdxl.json
Created November 6, 2023 06:49
Simple IP-Adapter Face workflow with SDXL model
{
"last_node_id": 18,
"last_link_id": 29,
"nodes": [
{
"id": 10,
"type": "EmptyLatentImage",
"pos": [
790,
390
@steffenr
steffenr / file_media_entity.php
Last active February 27, 2023 18:33
[Drupal 8] Create file/ media_entity programmatically
<?php
$filesystem = \Drupal::service('file_system');
// Create file entity.
$image = File::create();
$image->setFileUri($destination);
$image->setOwnerId(\Drupal::currentUser()->id());
$image->setMimeType('image/' . pathinfo($destination, PATHINFO_EXTENSION));
$image->setFileName($filesystem->basename($destination));
$image->setPermanent();
$image->save();
@steffenr
steffenr / book-all-books-block.html.twig
Last active October 14, 2021 05:30
Sample used in our second blog post on theming with Twig in Drupal 8
{% for book_id, menu in book_menus %}
<nav id="book-block-menu-{{ book_id }}" class="book-block-menu">
{{ menu }}
</nav>
{% endfor %}
@steffenr
steffenr / themename.info.yml
Created August 11, 2016 18:07
Embed external fonts in Drupal 8 theme (fonts are added in custom themename.libraries.yml)
name: Theme name
type: theme
description: Theme description
package: Custom
core: 8.x
libraries:
- themename/fonts
- themename/global-styling
base theme: classy
@steffenr
steffenr / THEMENAME_theme_suggestions_container_alter.php
Created November 28, 2019 07:10
Custom theme suggestions for container elements in drupal 8
<?php
/**
* Implements hook_theme_suggestions_alter() for container.
*/
function THEMENAME_theme_suggestions_container_alter(array &$suggestions, array &$variables)
{
$name = '';
$type = '';
if (isset($variables['element']['#name'])) {