Skip to content

Instantly share code, notes, and snippets.

View quackbarc's full-sized avatar
🧱
throwing bricks at people

chromacoat dreamkey quackbarc

🧱
throwing bricks at people
View GitHub Profile
@quackbarc
quackbarc / 2.0_paginators.py
Created March 22, 2022 07:01
some paginators for discord.py 2.0.0@45d498c
from typing import Callable, List, Optional
import discord
class Paginator(discord.ui.View):
r"""A dynamic paginator that uses a callback to generate embeds.
This should be passed in as a regular view to methods like
:meth:`discord.abc.Messageable.send`.
Parameters
@quackbarc
quackbarc / fizzbuzz_regex.md
Last active July 1, 2024 13:37
a fizzbuzz pattern made with pure regex
\b(?:(?<fizzbuzz>(?:(?:[369]|[258][0369]*[147]|(?:[147]|[258][0369]*[258])(?:[0369]|[147][0369]*[258])*(?:[28]|[147][0369]*[147]))*(?:0|(?:[147]|[258][0369]*[258])(?:[0369]|[147][0369]*[258])*5))+)|(?<buzz>\d*[05])|(?<fizz>(?:[0369]|[258][0369]*[147]|(?:[147]|[258][0369]*[258])(?:[0369]|[147][0369]*[258])*(?:[258]|[147][0369]*[147]))+))\b

insanity, as i'd like to call it. although it isn't fizzbuzz per se, it's the best you can get with regex. here's a regexr link to it with sample text.

this matches a number (within word boundaries) if it falls under any of the three groups:

  • fizzbuzz, which picks up numbers divisible by both 3 and 5, i.e. 15;
  • buzz, which picks up numbers divisible by 5; and
  • fizz, which picks up numbers divisible by 3.