Skip to content

Instantly share code, notes, and snippets.

View floffy-f's full-sized avatar

Florian Vincent floffy-f

  • INRIA
  • Grenoble
  • 20:56 (UTC +02:00)
View GitHub Profile
@floffy-f
floffy-f / colored_block.typ
Last active June 28, 2024 12:32
Colored block for theorems in Typst
#let theoremblock(title: [Theorem:], color: green, radius: (top-right: 2pt, bottom-right: 2pt), ..args, body) = {
// The top-title block needs only the
let tr = radius.at(
default: radius.at(
default: radius.at(
default: 0pt,
"right"
),
"top"
),
@floffy-f
floffy-f / md-like_blockquote.typ
Created June 28, 2024 09:19
Typst block quote like markdown
// A Typst block quote that looks like a `>` syntax sugar in markdown (e.g. github renderer).
// Put on top of relevant files.
#show quote.where(block: true): content => block(
fill: luma(245),
inset: (left: 3%, y: 10%),
radius: (right: 5pt),
stroke: (left: 1pt+luma(100)),
content
)
@floffy-f
floffy-f / lowtr_circulant.py
Last active January 29, 2024 14:49
Lower-triangular circulant embedding of pytorch vector
"""
Partially inspired from https://stackoverflow.com/a/70686229
"""
import torch as pt
def lowtr_circulant(diag: pt.Tensor, dim: int=-1):
r"""
From a vector ``diag``, computes its flipped circular embedding with zeros
above the diagonal.
Can be batched in left dimension(s).