Skip to content

Instantly share code, notes, and snippets.

@h4l
h4l / decode_avatar_url.py
Created April 22, 2024 15:35
Extract the NFT contract address and token ID from a Reddit avatar URL.
import base64
import re
def decode_avatar_url(avatar_url: str) -> tuple[str, int]:
"""Extract the NFT contract address and token ID from an avatar URL.
>>> avatar_url = 'https://i.redd.it/snoovatar/avatars/nftv2_bmZ0X2VpcDE1NToxMzdfOWQ4NTQyZWYxMjM3OTMzYmFkYmU4NjcyOTFmNmMwNDM0YjhkMzE1Y18xNTY_rare_9c019f39-3606-43fa-b14e-7dfb2dc3c12a.png'
>>> decode_avatar_url(avatar_url)
('0x9d8542ef1237933badbe867291f6c0434b8d315c', 156)
@h4l
h4l / Terminal output
Created November 7, 2022 19:45
Supabase's TLS cert rejected as invalid by Deno
$ export POSTGRES_HOSTNAME=db.XXXX.supabase.co
$ export POSTGRES_PASSWORD=XXXX
$ deno run --allow-env --allow-net deno-supabase.ts
Sending fatal alert BadCertificate
error: Uncaught (in promise) Error: The certificate used to secure the TLS connection is invalid.
throw new Error(
^
at Connection.#startup (https://deno.land/x/postgres@v0.17.0/connection/connection.ts:392:19)
at async Connection.startup (https://deno.land/x/postgres@v0.17.0/connection/connection.ts:491:11)
@h4l
h4l / gen-iiif-manifest.jq
Created November 4, 2022 10:44
Generate a IIIF Manifest from a bunch of info.json (IIIF Image API metadata) files
# This jq module generates a simple IIIF manifest from a list of IIIF Image API
# info.json documents.
#
# Usage:
# find . -name info.json | xargs jq > /tmp/manifest.json --indent 2 --slurp 'include "./gen-iiif-manifest"; manifest_for_info_json_docs'
def manifest_for_info_json_docs:
{
"@context": "http://iiif.io/api/presentation/2/context.json",
@h4l
h4l / reddit-collectable-avatar-backgrounds.json
Created September 29, 2022 20:28
JSON data detailing the background images of the first Reddit Collectable Avatars series.
[
{
"series": "5 Boro Bodega",
"title": "deadass from ny",
"backgroundImage": "https://i.redd.it/snoovatar/snoo_assets/BD9YiTQ0Keo_Background_Card_Deadass__1_.png",
"artist": {
"prefixedName": "u/bodegacatceo",
"title": "bodegacatceo"
}
},
@h4l
h4l / output
Created December 19, 2021 15:25
deno TextDecoderStream resource leak reproduction
$ deno --version
deno 1.17.0+3db18bf (canary, x86_64-apple-darwin)
v8 9.7.106.15
typescript 4.5.2
$ deno test text_decoder_stream_behaviour_test.ts
Check file:///private/tmp/text_decoder_stream_behaviour_test.ts
running 3 tests from file:///private/tmp/text_decoder_stream_behaviour_test.ts
test 1: TextDecoderStream leaks its TextDecoder's native decoder when a stream in its pipeline errors ... FAILED (17ms)
test 2: TransformStream using TextDecoder directly leaks a native decoder when a stream in its pipeline errors ... FAILED (5ms)
@h4l
h4l / anon-height-changes.csv
Last active February 21, 2019 23:57
On the 20th Feb ZwiftPower was reporting height changes in the aliases section of rider profiles from about the 18th Feb onwards. These are the anonymised changes in height that were published by ZwiftPower. ZP points are rounded to the nearest 50, rider IDs are removed, and times of changes are rounded to AM/PM.
rider_id zwiftpower_points date height_change
anon-0 200 Feb 19 pm -22
anon-1 250 Feb 18 pm 33
anon-1 250 Feb 18 pm -33
anon-2 250 Feb 19 pm 68
anon-2 250 Feb 19 pm -68
anon-3 250 Feb 19 pm 75
anon-4 250 Feb 19 pm 56
anon-5 250 Feb 20 pm 10
anon-6 300 Feb 20 pm -15
@h4l
h4l / chocolate-whiskey-marzipan-cake.md
Created November 4, 2018 20:31
Whiskey-Soaked Chocolate & Marzipan Cake Recipe

Keybase proof

I hereby claim:

  • I am h4l on github.
  • I am h4l (https://keybase.io/h4l) on keybase.
  • I have a public key ASCIX45tCBusRG7TFDEGT0PCgpSdgb2eALtYK3pw_PoAewo

To claim this, I am signing this object: