Skip to content

Instantly share code, notes, and snippets.

# Returns NaN.
function nan() {
return "+NaN" + 0
}
# Returns the binomial coefficient.
# It works, at least, when either n or k is a non-negative integer.
function binom(n, k, tmp) {
if (n == k || k == 0) {
return 1
=LAMBDA(
LET(
upRange, INDIRECT(ADDRESS(1, COLUMN()) & ":" & ADDRESS(ROW() - 1, COLUMN())),
lastNumber, LOOKUP(2, 1 / ISNUMBER(upRange), upRange),
IF(ISNUMBER(lastNumber),
lastNumber + 1,
""
)
)
)
@tueda
tueda / makeImage.m
Created December 25, 2023 14:15
Save a plot on WolframCloud.
(* cf. https://mathematica.stackexchange.com/a/278798 *)
makeImage[g_] := Block[{$ImageResolution = 300},
Export[CloudObject["output.png"], g, "PNG"];
Show[g]
];
@tueda
tueda / Makefile
Created December 16, 2023 07:20
Makefile for pLaTeX with relaxed filename restrictions
SOURCES := $(wildcard *.tex)
DOCUMENTS := $(SOURCES:.tex=.pdf)
CLEANFILES := \
$(foreach doc,$(DOCUMENTS),"$(doc)") \
$(foreach doc,$(SOURCES:.tex=.aux),"$(doc)") \
$(foreach doc,$(SOURCES:.tex=.log),"$(doc)")
all: $(DOCUMENTS)
clean:
def plot_data(data, *, figsize=None, columns=None, col_wrap=5, cat_threshold=5):
import matplotlib.pyplt as plt
import seaborn as sns
import pandas as pd
if not columns:
columns = data.columns
n_rows = len(columns) // col_wrap + 1
if not figsize:
figsize = (col_wrap * 4, n_rows * 3)
@tueda
tueda / EasyDatasets.md
Last active December 18, 2023 07:37
A biased list of easily accessible datasets.
@tueda
tueda / x
Last active May 1, 2024 12:43
Running a development version of FORM. #bin #sh #launcher #dev #form
#!/bin/bash
#
# Usage:
# ./x [check]
# [coverage|gprof|valgrind [<valgrind options>]|helgrind|drd|sanitize]
# [form|vorm|tform|tvorm|parform|parvorm]
# [args...]
#
# valgrind-options =
# [--leak-check=<no|summary|yes|full>]
@tueda
tueda / test11.frm
Created April 20, 2023 07:29
FORM vs. Wolfram: simple examples
* Example:
* form -D M=10 -D N=15 test11.frm
Symbol x1,...,x`M';
Local F = (x1+...+x`M')^`N';
.end
@tueda
tueda / FORM-source-notes.md
Last active May 2, 2023 01:20
Some personal notes for the source code of FORM: https://github.com/vermaseren/form.

Undocumented environment variables

External channels

  • FORM_PIPES

ParFORM

  • PF_LOG
  • PF_RBUFS
@tueda
tueda / auto-cherry-pick.sh
Last active April 11, 2023 10:49
Try "git cherry-pick" in a range of commits. #shell #git #cherry-pick
#!/bin/sh
#
# @file auto-cherry-pick.sh
#
# Usage:
# auto-cherry-pick.sh ref1...ref2:
#
set -eu
output=auto-cherry-pick.log