Skip to content

Instantly share code, notes, and snippets.

View jaantollander's full-sized avatar

Jaan Tollander de Balsch jaantollander

View GitHub Profile
@jaantollander
jaantollander / decorator.py
Last active December 30, 2023 21:50
Template for Python decorator function and class
import functools
def decorator(function):
"""A general decorator function"""
@functools.wraps(function)
def wrapper(*args, **kwargs):
# Write decorator function logic here
# Before function call
@jaantollander
jaantollander / quadtree.py
Created March 6, 2017 15:51
Quadtree implementation with Python and Numba
import numpy as np
import numba
from numba import deferred_type, optional, f8
node_type = deferred_type()
spec = (
("value", optional(f8[:, :])),
("center", f8[:]),
("length", f8),
@jaantollander
jaantollander / sympy_examples.ipynb
Last active October 4, 2023 11:16
SymPy examples.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaantollander
jaantollander / 01_multiple_dispatch.jl
Last active August 31, 2023 07:10
Multiple dispatch in Julia language
module MultipleDispatch
export A, A1, A2, f
# Abstract type
abstract type A end
# Concrete types
struct A1 <: A end
struct A2 <: A end
@jaantollander
jaantollander / .bashrc
Created August 10, 2021 04:35
Adding to PATH in idempotent way, that is, without repetition.
# https://unix.stackexchange.com/a/124447
add_to_path() {
case ":${PATH:=$1}:" in *:"$1":*) ;; *) PATH="$1:$PATH" ;; esac;
}
# Example
add_to_path $HOME/bin/julia-1.6.1/bin
@jaantollander
jaantollander / unicode-math-symbols.csv
Last active October 12, 2022 09:40
List of unicode math symbols (separator uses ^)
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 1 column, instead of 2. in line 6.
# Unicode characters and corresponding LaTeX math mode commands
# *************************************************************
#
# :Copyright: © 2011 Günter Milde
# :Date: Last revised 2011-11-08
# :Licence: This work may be distributed and/or modified under the
# conditions of the `LaTeX Project Public License`_,
# either version 1.3 of this license or (at your option)
# any later version.
#
@jaantollander
jaantollander / accounts.txt
Created August 14, 2022 06:25 — forked from simonmichael/accounts.txt
a sample *ledger chart of accounts (first 3 levels): combined personal & business, eg for a freelancer
assets
business
accounts receivable
bank
personal
accounts receivable
bank
cash
gifts
online
# OBJECTIVE: Install Arch Linux with encrypted root and swap filesystems with an ENCRYPTED BOOT and boot from UEFI. We will
also decrypt and mount our entire encrypted system using a single LUKS passphrase entry.
# Note: This method supports both dedicated Arch installs and those who wish to install Arch on a multi-OS-UEFI booting system.
# External USB HDD/SSD Installers Notes: Encrypted Arch installs can be booted and run from an external USB HDD or SSD, but
# only when the installation is correctly set up. There are several necessary changes to my standard procedure you'll want
# to make during the install process. Read my External USB HDD/SSD Installation section below before proceeding.
@jaantollander
jaantollander / pkg.jl
Last active September 15, 2021 06:08
Template for creating a Julia package with PkgTemplates.jl to current working directory.
using PkgTemplates
template = Template(;
user="jaantollander",
authors="Jaan Tollander de Balsch",
julia=v"1.6",
dir=".",
plugins=[
License(; name="MIT"),
GitHubActions(),
Documenter{GitHubActions}(),
@jaantollander
jaantollander / value_based_dispatch.jl
Last active July 25, 2021 07:10
Value-based dispatch in Julia language
module ValueBasedDispatch
export MyType, A, B, C, f
abstract type MyType end
struct A <: MyType end
struct B <: MyType end
struct C <: MyType end
f(::Type{A}) = "Dispatch on argument A"