Skip to content

Instantly share code, notes, and snippets.

View artlung's full-sized avatar
💭
🤖

Joe Crawford artlung

💭
🤖
View GitHub Profile
@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 January 6, 2026 15:48
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)
@artlung
artlung / .htaccess
Last active February 12, 2026 17:26
.htaccess llm blocking
# https://serverfault.com/questions/1162651/blocking-bots-with-apache-htaccess
RewriteCond %{HTTP_USER_AGENT} ^.*(AdsBot-Google|Amazonbot|anthropic-ai|Applebot|Applebot-Extended|AwarioRssBot|AwarioSmartBot|Bytespider|CCBot|ChatGPT|ChatGPT-User|Claude-Web|ClaudeBot|cohere-ai|DataForSeoBot|Diffbot|GPTBot|ImagesiftBot|magpie-rawler|omgili|Omgilibot|peer39_crawler|PerplexityBot|YouBot|AhrefsBot|Barkrowler|SemrushBot|DotBot).*$ [NC]
# https://www.jwz.org/blog/2025/05/user-agent-blocking/#comment-259200
RewriteRule .* - [F,L]