Skip to content

Instantly share code, notes, and snippets.

@ntjess
ntjess / gantt.typ
Last active May 2, 2024 00:00
Colorful, Date-Aligned Gantt Chart in Typst
#let _records-to-dict(records) = {
let formatted = (:)
for r in records {
for (k, v) in r {
let cur = formatted.at(k, default: ())
cur.push(v)
formatted.insert(k, cur)
}
}
formatted
@ntjess
ntjess / git-graph.typ
Last active May 1, 2024 05:41
Generate git graphs in typst
#import "@preview/cetz:0.2.0"
#let d = cetz.draw
#let offset(anchor, x: 0, y: 0) = {
(v => cetz.vector.add(v, (x, y)), anchor)
}
#let default-colors = (red, orange, yellow, green, blue, purple, fuchsia, gray)
#let color-boxed(..args) = {
set text(0.8em)
box(
@ntjess
ntjess / wrap-content.typ
Last active January 26, 2024 07:23
Typst: Auto wrap text (and some content types) around a figure
🚧🚧🚧 This code has moved! 🚧🚧🚧
View the latest changes at https://github.com/ntjess/wrap-it
import numpy as np
import torch
from torch.nn.functional import conv2d
from skimage.util.shape import view_as_windows
# Try with values that don't have transpose symmetry
input_matrix_ = np.array(
[[3,9,0,1],
[2,8,1,1],
[3,4,8,1],
@ntjess
ntjess / duplicates.py
Last active April 16, 2023 03:11 — forked from tfeldmann/duplicates.py
Fast duplicate file finder written in python
#!/usr/bin/env python
"""
Fast duplicate file finder.
Usage: duplicates.py <folder> [<folder>...]
Based on https://stackoverflow.com/a/36113168/300783
Modified for Python3 with some small code improvements.
"""
import os
import sys
@ntjess
ntjess / dumyvias.py
Created December 18, 2020 00:24
Minimal example for 'via' detection in s3a
import numpy as np
import cv2 as cv
from s3a import FR_SINGLETON, ComplexXYVertices, REQD_TBL_FIELDS as RTF, S3A, appInst
from s3a.processing import ProcessIO
from s3a.processing.processing import GlobalPredictionProcess
from pyqtgraph.Qt import QtCore
def findCircles(image: np.ndarray, nCircles=5, minRadius=6, maxRadius=200):
# row-col to x-y
@ntjess
ntjess / __init__.py
Last active December 3, 2020 21:28
Image Exporter plugin
from s3a.parameditors import ParamEditorPlugin, ParamEditor, FR_SINGLETON
from skimage import io
class InfoExporterPlugin(ParamEditorPlugin):
name = 'Info Exporter'
@classmethod
def __initEditorParams__(cls):
super().__initEditorParams__()
cls.toolsEditor = ParamEditor.buildClsToolsEditor(cls, 'Tools')
import numpy as np
import matplotlib.pyplot as plt
x = np.random.normal((3,3))
plt.imshow(x)
plt.show()