Mathb
Mathematics pastebin software that powered MathB.in from 2012 to 2025
Install / Use
/learn @susam/MathbREADME
MathB
MathB is a mathematics pastebin software that powered MathB.in from
2012 to 2025. It is a web-based service meant for sharing snippets of
mathematical text with others on the world wide web.
Contents
- Features
- Quick Start
- Custom Directory Paths
- Data Files
- Runtime Options
- Templates Files
- Static Files
- Live Directory
- Save PDF
- History
- License
- Support
- Channels
- More
Features
- Minimalist user interface that has not changed much over a decade.
- Live preview of Markdown and LaTeX content as it is typed.
- Support for mixing Markdown and LaTeX code freely.
- Printing a post to PDF or paper prints only the rendered content.
- All UI elements apart from rendered content are excluded from prints.
- No web cookies.
- No web analytics.
Quick Start
This section explains how to run this project locally. The steps assume a macOS, Debian, or Debian-based Linux distribution. However, it should be possible to adapt these steps for another operating system.
-
Install SBCL and Git.
On macOS, enter the following command if you have Homebrew:
brew install sbcl gitOn Debian, Ubuntu, or another Debian-based Linux system, enter the following command:
sudo apt-get update sudo apt-get install sbcl git -
Install Quicklisp with the following commands:
curl -O https://beta.quicklisp.org/quicklisp.lisp sbcl --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --quit sbcl --load ~/quicklisp/setup.lisp --eval "(ql:add-to-init-file)" --quit -
From here on, we assume that all commands are being run in the top-level directory of this project. Set up dependencies necessary to run this project by running this command within the top-level directory of this project:
make liveThis creates a
_livedirectory within the current directory and copies all necessary dependencies to it. -
Create data and log directories:
sudo mkdir -p /opt/data/mathb/ /opt/log/mathb/ sudo cp -R meta/data/* /opt/data/mathb/ sudo chown -R "$USER" /opt/data/mathb/ /opt/log/mathb/By default, MathB reads post data from and writes posts to
/opt/data/mathb/. It writes logs to/opt/log/mathb/by default. The next section explains how to make it use custom directory paths. -
Run MathB with the following command:
sbcl --load mathb.lisp -
Visit http://localhost:4242/ with a web browser to use MathB.
After starting MathB in this manner, click on the various navigation links and make a new post to confirm that MathB is working as expected.
Custom Directory Paths
In the previous section, we created a data directory at
/opt/data/mathb/ and a log directory at /opt/log/mathb/. By
default, MathB writes new posts to and reads posts from this directory
path. To make it use a different path for the data directory, set the
variable named *data-directory* before loading it. Similarly, set
the variable named *log-directory* to specify a different path for
the log directory. The following steps demonstrate how to do this:
-
Create data directory at a custom path, say, at
~/data:mkdir -p ~/data/ ~/log/ cp -R meta/data/* ~/data/ -
Run MathB with the following command:
sbcl --eval '(defvar *data-directory* "~/data/")' \ --eval '(defvar *log-directory* "~/log/")' \ --load mathb.lisp -
Visit http://localhost:4242/ with a web browser to use MathB.
After starting MathB in this manner, click on the various navigation links and make a new post to confirm that MathB is working as expected.
Data Files
The data directory contains the following files:
-
opt.lisp: This file contains a property list that can be modified to alter the behaviour of MathB. This is explained in detail in the next section. -
slug.txt: This file contains the ID of the latest post successfully saved. -
post/X/Y/*.txt: These files contain the actual posts submitted by users whereXandYare placeholders for two integers explained shortly. Each.txtfile contains a post submitted by a user.
In the last point, the placeholder X is the post ID divided
by 1000000. The placeholder Y is the post ID divided by 1000. For
example, for a post with ID 1, X is 0 and Y is 0, so a post
with this ID is saved at post/0/0/1.txt. For a more illustrative
example, consider a post with with ID 2301477. Now X is 2 and Y
is 2301, so a post with this ID is saved at
post/2/2301/2301477.txt.
Let us call each X directory a short-prefix directory and each Y
directory under it a long-prefix directory. As a result of the
calculation explained above, each short-prefix directory contains a
maximum of 1000 long-prefix directories and each long-prefix directory
contains a maximum of 1000 post files. Thus, each short-prefix
directory contains a maximum of one million post files under it.
Runtime Options
MathB reads runtime properties from opt.lisp. This file contains a
property list. Each property in this list is followed by a value for
that property. This property list may be used to alter the behaviour
of MathB. A list of all supported properties and their descriptions
is provided below.
-
:lock-down(default isnil): A value oftmakes MathB run in lock-down mode, i.e., existing posts cannot be viewed and new posts cannot be submitted. -
:read-only(default isnil): A value oftmakes MathB run in read-only mode, i.e., old posts can be viewed but new posts cannot be made. If the values of both this property and the previous property arenil, then MathB runs normally in read-write mode. -
:min-title-length(default is0): The minimum number of characters allowed in the title field. -
:max-title-length(default is120): The maximum number of characters allowed in the title field. -
:min-name-length(default is0): The minimum number of characters allowed in the name field. -
:max-name-length(default is120): The maximum number of characters allowed in the name field. -
:min-code-length(default is1): The minimum number of characters allowed in the code field. -
:max-code-length(default is10000): The maximum number of characters allowed in the code field. -
:global-post-interval(default is0): The minimum interval (in seconds) required between two consecutive successful posts.Example: If this value is
10and one client submits a new post at 10:00:00 and another client submits a post at 10:00:07, the post of the second client is rejected with an error message that they must wait for 3 more seconds before submitting the post. An attempt to submit the post at 10:00:10 or later would succeed, provided that no other client submitted another post between 10:00:10 and the second client's attempt to make a post. -
:client-post-interval(default is0): The minimum interval (in seconds) between two consecutive successful posts allowed from the same client.Example: If this value is
10and one client submits a new post at 10:00:00, then the same client is allowed to make the next successful post submission at 10:00:10 or later. If the same client submits another post at 10:00:07, the post is rejected with an error message that they must wait for 3 more seconds before submitting the post. This does not affect the posting behaviour for other clients. For example, another client can successfully submit their post at 10:00:07 while the first client cannot. -
:expect(default isnil): A list of strings. At least one string from this list must occur in the submitted code field.Example: If this value is
("\(" "\[")and the submitted post contains\[ 1 + 1 = 2. \]in the code field, then the post is accepted successfully. However, if the submitted code contains only1 + 1 = 2, then the post is rejected because neither the string"\("nor the string"\["occurs in the code field of this submission. -
:block(default isnil): A list of strings that are not allowed in a post. If a post contains any string in this list, the post is rejected and the input form is returned intact to the client.Example: If this value is
("berk" "naff" "xxx")and a client posts content which contains the stringxxxin any field (code, title, or name), the post is rejected. -
:ban(default isnil): A list of IPv4 or IPv6 address prefixes. If the address of the remote client (as it appears in the logs) matches any prefix in this list, the post from the client is rejected. The prefixes must be expressed as simple string literals. CIDRs, globs, regular expressions, etc. are not supported. A dollar sign ($) at the end of a prefix string matches the end of the client's address string.Example: Let us consider a value of
("10.1." "10.2.0.2" "10.3.0.2$")for this property. If a client from IP address10.1.2.3submits a post, it is rejected because the prefix10.1.matches this IP address. If a client from IP address10.2.0.23submits a post, it is rejected because the prefix10.2.0.2matches this IP address. If a client from IP address10.3.0.2submits a po
Related Skills
node-connect
337.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
