Skip to content

Instantly share code, notes, and snippets.

@darvil82
darvil82 / british_python.py
Created July 25, 2022 18:59
British python
class BritishNaming(type):
def __new__(mcs, *args):
cls = super().__new__(mcs, *args)
cls.__init__ = cls.__innit__
return cls
class MyBritishClass(metaclass=BritishNaming):
def __innit__(self):
print("I am british now ig")
@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.
@pedrominicz
pedrominicz / Hylo.hs
Created November 15, 2019 15:44
Catamorphisms, Anamorphisms, and Hylomorphisms.
{-# LANGUAGE UndecidableInstances #-}
module Hylo where
-- An attempt to derive a hylomorphism from the type signature (at the time of
-- writing I don't recall ever seeing the implementation of one).
type Algebra f a = f a -> a
type Coalgebra f a = a -> f a
@pedrominicz
pedrominicz / Everything.md
Last active May 28, 2024 21:56
Every Gist I've written.

The originality of these Gists varies drastically. Most are inspired by the work of others, in that case, all merit goes to the original authors. I have linked everything used as reference material on the Gists themselves.

Haskell

According to all known laws of aviation, there is no way a bee should be able to fly.
Its wings are too small to get its fat little body off the ground.
The bee, of course, flies anyway because bees don't care what humans think is impossible.
Yellow, black. Yellow, black. Yellow, black. Yellow, black.
Ooh, black and yellow!
Let's shake it up a little.
Barry! Breakfast is ready!
Coming!
Hang on a second.
Hello?
@chrisdone
chrisdone / Printf.idr
Last active May 27, 2024 13:01
Type-safe dependently-typed printf in Idris
module Printf
%default total
-- Formatting AST.
data Format
= FInt Format
| FString Format
| FOther Char Format
| FEnd
@maxtruxa
maxtruxa / Antonyms.md
Last active June 18, 2024 18:39
A list of common terms used in programming and their respective antonyms.

Antonym List

Note: The table headings (positive/negative) are not necessarily meaningful.

Positive Negative
acquire release
add remove (e.g. an item), subtract (arithmetic)
advance retreat
allocate deallocate (correct), free (common)
allow deny