Skip to content

Instantly share code, notes, and snippets.

@maxtruxa
maxtruxa / Antonyms.md
Last active November 15, 2024 20:10
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
@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
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?
@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

@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
@quackbarc
quackbarc / fizzbuzz_regex.md
Last active September 4, 2024 19:14
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.
@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")
@FreyaHolmer
FreyaHolmer / GpuPrinter.cginc
Last active November 1, 2024 23:31
A unity shader .cginc to draw numbers in the fragment shader - see the first comment below for example usage!
///////////////////////////////////////////////////////////////////////////////
// ABOUT: A unity Shader .cginc to draw numbers in the fragment shader
// AUTHOR: Freya Holmér
// LICENSE: Use for whatever, commercial or otherwise!
// Don't hold me liable for issues though
// But pls credit me if it works super well <3
// LIMITATIONS: There's some precision loss beyond 3 decimal places
// CONTRIBUTORS: yes please! if you know a more precise way to get
// decimal digits then pls lemme know!
// GetDecimalSymbolAt() could use some more love/precision
@brendanzab
brendanzab / open-interperters.ml
Last active August 25, 2024 02:28
Open interpreters using polymorphic variants and extensible variants.
(** This is a demonstration of implementing interpreters in an extensible way
that offers a partial solution to the expression problem. The idea is that
the language can be extended with more features after the fact, without
altering previous definitions. It also has the benefit of grouping the
related extensions to the syntax and semantic domains together with the
relevant evaluation rules in a per-feature way.
This approach used is similar to the one described by Matthias Blume in
{{:https://www.microsoft.com/en-us/research/video/records-sums-cases-and-exceptions-row-polymorphism-at-work/}
Records, sums, cases, and exceptions: Row-polymorphism at work}.
@AndrasKovacs
AndrasKovacs / TwoStageRegion.md
Last active November 13, 2024 09:30
Lightweight region memory management in a two-stage language