Skip to content

Instantly share code, notes, and snippets.

View Demonstrandum's full-sized avatar
🏫
Studying

S Knutsen Demonstrandum

🏫
Studying
  • University of Nottingham
  • Britanniarum Regnum
  • 09:54 (UTC +01:00)
View GitHub Profile
@Demonstrandum
Demonstrandum / macros.tex
Last active April 17, 2024 17:38
Basic macros.
\newcommand{\cat}[1]{\mathscr{#1}}
\newcommand{\fcat}[1]{\mathbf{#1}}
\newcommand{\FF}{\mathbb{F}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\II}{\mathbb{I}}
\newcommand{\C}{\cat{C}}
@Demonstrandum
Demonstrandum / vec.py
Created October 4, 2022 19:36
Vector class from Python tuple.
class Vec(tuple):
def __new__(cls, x, y=None, z=None):
if y is None:
return super(Vec, cls).__new__(cls, x)
if z is None:
return super(Vec, cls).__new__(cls, (x, y))
return super(Vec, cls).__new__(cls, (x, y, z))
def dot(self, other):
return sum(x0 * x1 for (x0, x1) in zip(self, other))
def __add__(self, other):
@Demonstrandum
Demonstrandum / raster.py
Last active March 13, 2022 14:11
Rasterisation implementation for primitive shapes.
import numpy as np
class NormalPoint:
"""
Normalised Cartesian coördinates
in the space [-1; 1]×[-1; 1] ⊆ ℝ²
"""
def __init__(self, x, y):
self.x, self.y = x, y
def polar(t):
@Demonstrandum
Demonstrandum / cube.rb
Created June 5, 2021 22:11
Cube in the terminal (old).
WIDTH = `tput cols`.to_i - 1 || 80
HEIGHT = `tput lines`.to_i - 1 || 40
FPS = 60
include Math
class Array
def x; self[0]; end
def y; self[1]; end
def z; self[2]; end
@Demonstrandum
Demonstrandum / door.link.ts
Last active October 30, 2023 18:33
download music from door.link.
@Demonstrandum
Demonstrandum / tacit.py
Created June 3, 2020 20:16
Tacit programming with Currying and Composition in Python.
# # Exaple:
# ```py
# from tacit import *
#
# @fn
# def f(x, y):
# return 2 * (x + y)
#
# @fn
# def g(x): return x + 3
@Demonstrandum
Demonstrandum / simp-deps.svg
Created March 21, 2020 03:14
Simp'O'Matic Dependencies
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Demonstrandum
Demonstrandum / init
Created March 12, 2020 15:33
Sinatra Now Test
init
@Demonstrandum
Demonstrandum / catbread.gif
Last active December 22, 2021 17:52
Bread
catbread.gif
@Demonstrandum
Demonstrandum / basic_ruby.rb
Created July 7, 2019 17:48
Helping Sam Frost
def f x; x**2 + 2*x + 1; end
def integrate sym, a, b
dx = 0.001
fn = method sym
dx * (a..b - dx).step(dx).map(&fn).sum
end
puts integrate :f, 2, 4