Skip to content

Instantly share code, notes, and snippets.

View artlung's full-sized avatar
💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
<?php
// By Joe Crawford joe@artlung.com
// January 2024
// intended to be run from the command line
// php thumb-2024.php
// place images in the same directory as this script and their names in the array below
// or place urls in the array below - filenames must be unique
// height and width of the final image, for now the math relies on everything being square
@artlung
artlung / htsearch
Last active March 19, 2026 15:40
Redirects to a different search path, in Perl
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
my $query = $ENV{'QUERY_STRING'} || '';
my ($words) = $query =~ /words=([^&]+)/;
if (defined $words) {
$words =~ s/\+/ /g; # Replace + with space
$words =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; # Decode URL-encoded characters
print "Location: /search/?q=$words\n\n";
} else {
@artlung
artlung / H6UblABi3KU.json
Last active March 18, 2026 15:51
yt-dlp --dump-json example (18 March 2026)
{
"id": "H6UblABi3KU",
"title": "CSSBattle for MARCH 17 (2026)",
"formats": [
{
"format_id": "sb3",
"format_note": "storyboard",
"ext": "mhtml",
"protocol": "mhtml",
"acodec": "none",
<article class="h-entry">
<a class="u-url u-bookmark-of" href="{{ url }}">{{ title }}</a>
<a href="https://news.indieweb.org/en" class="u-category"></a>
<small><time class="dt-published" datetime="{{ published_datetime|date("c") }}"></time></small>
<small><a href="{{ like_permalink }}" class="u-url"></a></small>
</article>
/**
* Given an array of objects representing bears in a forest, each with a
* name and hunger level, return the names of all bears whose hunger
* level is above the forest average, sorted alphabetically.
*
* @param bears{name: string, hunger: number}[]
* @returns {string[]}
*/
function hungryBears(bears) {
// Was happy to reacquaint myself with [],reduce and "".localeCompare
@artlung
artlung / rsvp.html.twig
Last active April 16, 2026 01:31
rsvp.html.twig
<div class="h-entry" id="{{ rsvp.id }}">
<p class="p-summary">
{% include 'rsvp_author_tag.html.twig' %}
RSVPs <span class="p-rsvp">{{ rsvp.yes_no_maybe }}</span>
to <a href="{{ event.url }}" class="u-in-reply-to">{{ event.name }}</a>
({{ event.date }})
</p>
<time class="dt-published" datetime="{{ rsvp.published_datetime }}"></time>
<a class="u-url" href="{{ rsvp.url }}"></a>
</div>
/**
*
* Replaces sequences of repeated numeric characters in a string with the length of that sequence.
*
* @param $inputString string A string of numeric characters
* @param $numberToReplaceWithLengthsOf int A single digit (0-9)
*
*/
function replaceRepeats(string $inputString, int $numberToReplaceWithLengthsOf): string
{
/* style.css | https://test-lprry.statichost.eu/assets/css/style.css */
.snaps-vertical img {
/* width: 215px; */
width: clamp(215px, 100%, 300px);
transition: 300ms transform;
height: auto;
}
@artlung
artlung / -artlung-transitions.scss
Created December 3, 2025 23:13
Transitions on artlung.com as of 2025-12-03
@view-transition {
navigation: auto;
}
/* Customize the default animation behavior */
// TODO:
// view transition name
// view transition class
1 REM ARTLUNG START
3 CALL CLEAR
5 CALL CHAR(33, "000000FFFFFFFFFF")
7 CALL VCHAR(11, 1, 33)
11 CALL VCHAR(11, 2, 33)
15 CALL VCHAR(11, 3, 33)
19 CALL VCHAR(11, 4, 33)
23 CALL VCHAR(11, 5, 33)
27 CALL VCHAR(11, 6, 33)
31 CALL VCHAR(11, 7, 33)