<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Eli Bendersky's website - Blogging</title><link href="https://eli.thegreenplace.net/" rel="alternate"/><link href="https://eli.thegreenplace.net/feeds/blogging.atom.xml" rel="self"/><id>https://eli.thegreenplace.net/</id><updated>2025-10-25T13:23:02.691750-07:00</updated><entry><title>LaTeX, LLMs and Boring Technology</title><link href="https://eli.thegreenplace.net/2025/latex-llms-and-boring-technology/" rel="alternate"/><published>2025-10-25T06:20:00-07:00</published><updated>2025-10-25T13:23:02.691750-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2025-10-25:/2025/latex-llms-and-boring-technology/</id><summary type="html">&lt;p&gt;Depending on your particular use case, &lt;a class="reference external" href="https://boringtechnology.club/"&gt;choosing boring technology&lt;/a&gt;
is often a good idea. Recently, I've been thinking more and more about how
the rise and increase in power of LLMs affects this choice.&lt;/p&gt;
&lt;p&gt;By definition, boring technology has been around for a long time. Piles of
content have been …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Depending on your particular use case, &lt;a class="reference external" href="https://boringtechnology.club/"&gt;choosing boring technology&lt;/a&gt;
is often a good idea. Recently, I've been thinking more and more about how
the rise and increase in power of LLMs affects this choice.&lt;/p&gt;
&lt;p&gt;By definition, boring technology has been around for a long time. Piles of
content have been written and produced about it: tutorials, books, videos,
reference manuals, examples, blog posts and so on. All of this is consumed
during the LLM training process, making LLMs better and better at reasoning
about such technology.&lt;/p&gt;
&lt;p&gt;Conversely, &amp;quot;shiny technology&amp;quot; is new, and has much less material available. As
a result, LLMs won't be as familiar with it. This applies to many domains, but
one specific example for me personally is in the context of LaTeX.&lt;/p&gt;
&lt;p&gt;LaTeX certainly fits the &amp;quot;boring technology&amp;quot; bill. It's decades old, and has
been the mainstay of academic writing since the 1980s. When I used it for the
first time in 2002 (for a project report in my university AI class), it was
already very old. But people keep working on it and fixing issues; it's easy to
install and its wealth of capabilities and community size are staggering.
Moreover, people keep working &lt;em&gt;with&lt;/em&gt; it, producing more and more content and
examples the LLMs can ingest and learn from.&lt;/p&gt;
&lt;p&gt;I keep hearing about the advantages of new and shiny systems like
Typst. However, with the help of LLMs, almost none of the advantages seem
meaningful to me. LLMs are &lt;em&gt;great&lt;/em&gt; at LaTeX and help a lot with learning or
remembering the syntax, finding the right packages, deciphering errors and
even generating tedious parts like tables and charts, significantly reducing
the need for scripting &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can use LLMs either as standalone or fully integrated into your LaTeX
environment; Overleaf has a built-in AI helper, and for local editing you can
use VSCode plugins or other tools. I'm personally &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/notes-on-using-latex-to-generate-formulae/"&gt;content with TeXstudio&lt;/a&gt;
and use LLMs as standalone help, but YMMV.&lt;/p&gt;
&lt;p&gt;There are many examples where boring technology and LLMs go well together. The
main criticism of boring technology is typically that it's &amp;quot;too big, full of
cruft, difficult to understand&amp;quot;. LLMs really help cutting through the learning
curve though, and all that &amp;quot;cruft&amp;quot; is very likely to become useful some time in
the future when you graduate from the basic use cases.&lt;/p&gt;
&lt;p&gt;To be clear: Typst looks really cool, and kudos to the team behind it! All I'm
saying in this post is that for me - personaly - the choice for now is to stick
with LaTeX as a &amp;quot;boring technology&amp;quot;.&lt;/p&gt;
&lt;div class="section" id="appendix-some-examples-of-llms-being-helpful-with-latex"&gt;
&lt;h2&gt;Appendix: some examples of LLMs being helpful with LaTeX&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;For finding the right math symbols, I rarely need to scan reference materials
any longer. LLMs will easily answer questions like &amp;quot;what's that squiggly
Greek letter used in math, and its latex symbol?&amp;quot; or &amp;quot;write the latex for
Green's theorem, integral form&amp;quot;.
For the trickiest / largest equations, LLMs are very good at &amp;quot;here's a picture
I took of my equation, give me its latex code&amp;quot; these days &lt;a class="footnote-reference" href="#footnote-2" id="footnote-reference-2"&gt;[2]&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;&amp;quot;Here's a piece of code and the LaTeX error I'm getting on it; what's wrong?&amp;quot;&lt;/p&gt;
&lt;p&gt;This is made more ergonomic by editor integrations, but I personally find that
LaTeX's error message problem is hugely overblown. 95% of the errors are
reasonably clear, and serious sleuthing is only rarely required in practice.
In that minority of cases, pasting some code and the error into a standalone
LLM isn't a serious time drain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Generating TikZ diagrams and plots. For this, the hardest part is getting
started and finding the right element names, and so on. It's very useful to
just ask an LLM to emit something initial and then tweak it manually later,
as needed. You can also ask the LLM to explain each thing it emits in
detail - this is a great learning tool for deeper understanding.&lt;/p&gt;
&lt;p&gt;Recently I had luck going &amp;quot;meta&amp;quot; with this: when the diagram has repetitive
elements, I may ask the LLM to &amp;quot;write a Python program that generates a TikZ
diagram ...&amp;quot;, and it works well.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Generating and populating tables, and converting them from other data
formats or screenshots.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Help with formatting and typesetting (how do I change margins to XXX and
spacing to YYY).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;p class="first"&gt;When it comes to scripting, I generally prefer sticking to real
programming languages anyway. If there's anything non-trivial to
auto-generate I wouldn't use a LaTeX macro, but would write a Python
program to generate whatever I need and embed it into the document
with something like &lt;tt class="docutils literal"&gt;\input{}&lt;/tt&gt;.&lt;/p&gt;
&lt;p class="last"&gt;Typst's scripting system may be marketed as &amp;quot;clean and powerful&amp;quot;, but
why learn yet another scripting language?&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-2" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;p class="first"&gt;Ignoring LaTeX's equation notation and doing their own thing is one of
the biggest mistakes Typst makes, in my opinion. LaTeX's notation may
not be perfect, but it's near universal at this point with support in
almost all math-aware tools.&lt;/p&gt;
&lt;p class="last"&gt;Typst's math mode is a clear sign of the second system effect, and isn't
&lt;a class="reference external" href="https://laurmaedje.github.io/posts/math-mode-problem/"&gt;even stable&lt;/a&gt;.&lt;/p&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content><category term="misc"/><category term="Math"/><category term="Blogging"/><category term="Software &amp; Tools"/></entry><entry><title>Notes on using LaTeX to generate formulae</title><link href="https://eli.thegreenplace.net/2025/notes-on-using-latex-to-generate-formulae/" rel="alternate"/><published>2025-10-11T08:13:00-07:00</published><updated>2025-10-11T15:15:50.694555-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2025-10-11:/2025/notes-on-using-latex-to-generate-formulae/</id><summary type="html">&lt;p&gt;This post collects some notes on using LaTeX to render mathematical documents
and formulae, mostly focused on a Linux machine. For background, I typically
use LaTeX for one of two (related) purposes:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Render math for my blog posts, which are usually written
&lt;a class="reference external" href="https://eli.thegreenplace.net/2014/blogging-setup-with-pelican/"&gt;using reStructuredText&lt;/a&gt;.
This sometimes includes diagrams generated using …&lt;/li&gt;&lt;/ol&gt;</summary><content type="html">&lt;p&gt;This post collects some notes on using LaTeX to render mathematical documents
and formulae, mostly focused on a Linux machine. For background, I typically
use LaTeX for one of two (related) purposes:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Render math for my blog posts, which are usually written
&lt;a class="reference external" href="https://eli.thegreenplace.net/2014/blogging-setup-with-pelican/"&gt;using reStructuredText&lt;/a&gt;.
This sometimes includes diagrams generated using TikZ.&lt;/li&gt;
&lt;li&gt;Write personal (unpublished) notes on math-y subjects entirely in LaTeX.
These are typically short (up to 10-20 pages), single-subject booklets.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I don't currently use LaTeX for either precise typesetting or for
authoring very large, book-sized documents.&lt;/p&gt;
&lt;div class="section" id="editing"&gt;
&lt;h2&gt;Editing&lt;/h2&gt;
&lt;p&gt;For day-to-day authoring, I find &lt;a class="reference external" href="https://www.texstudio.org/"&gt;TeXstudio&lt;/a&gt; to be
excellent. It has everything I need for local editing with a convenient preview
window. I really like that TeXstudio doesn't hide the fact that it's just a
graphical veneer on top of command-line LaTeX tooling, and lets you examine what
it's doing through logs.&lt;/p&gt;
&lt;p&gt;Note that web-based solutions like Overleaf exist; I can see myself using that,
especially if collaborating with others or having to author LaTeX from a
diverse set of computers and OSes, but for local editing of git-backed text
files, TeXstudio is great.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="converting-to-other-formats-with-pandoc"&gt;
&lt;h2&gt;Converting to other formats with pandoc&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://pandoc.org/"&gt;pandoc&lt;/a&gt; is very capable for converting documents from
LaTeX to other formats. Recently I find that it's easier to write math-heavy
blog posts in LaTeX, and then convert them to reStructuredText with &lt;tt class="docutils literal"&gt;pandoc&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;For example, the recent &lt;a class="reference external" href="https://eli.thegreenplace.net/2025/hilbert-space-treating-functions-as-vectors/"&gt;post on Hilbert spaces&lt;/a&gt;
was written like this and then converted using this command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pandoc -f latex -s -t rst hilbert.tex
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The resulting reStructuredText is very readable and requires very little
tweaking before final publishing. &lt;tt class="docutils literal"&gt;pandoc&lt;/tt&gt; supports many formats, so if you
use Markdown or something else, it should work similarly well.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="rendering-standalone-formulae-or-diagrams"&gt;
&lt;h2&gt;Rendering standalone formulae or diagrams&lt;/h2&gt;
&lt;p&gt;A useful feature of LaTeX tooling is the ability to render a specific formula
in standalone mode to an image. We can write the formula into its own file
(call it &lt;tt class="docutils literal"&gt;standaloneformula.tex&lt;/tt&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;\documentclass&lt;/span&gt;&lt;span class="na"&gt;[preview]&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;standalone&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\usepackage&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;amsmath&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;\begin&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;document&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="s"&gt;\(&lt;/span&gt;&lt;span class="nb"&gt;&lt;/span&gt;
&lt;span class="nv"&gt;\int&lt;/span&gt;&lt;span class="nb"&gt;_{&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;\infty&lt;/span&gt;&lt;span class="nb"&gt;}^&lt;/span&gt;&lt;span class="nv"&gt;\infty&lt;/span&gt;&lt;span class="nb"&gt; e^{&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;x^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="nb"&gt;}&lt;/span&gt;&lt;span class="nv"&gt;\,&lt;/span&gt;&lt;span class="nb"&gt;dx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;\sqrt&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;\pi&lt;/span&gt;&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;span class="s"&gt;\)&lt;/span&gt;
&lt;span class="k"&gt;\end&lt;/span&gt;&lt;span class="nb"&gt;{&lt;/span&gt;document&lt;span class="nb"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In case you were wondering, this is the Gaussian integral:&lt;/p&gt;
&lt;object class="align-center" data="https://eli.thegreenplace.net/images/math/1a96fcbd751829566b9da856edd88c2916739440.svg" style="height: 41px;" type="image/svg+xml"&gt;\[\int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt{\pi}\]&lt;/object&gt;
&lt;p&gt;Once we have that standalone &lt;tt class="docutils literal"&gt;.tex&lt;/tt&gt; file, there's a number of things we can
do. First, the &lt;a class="reference external" href="https://www.tug.org/texlive/"&gt;texlive&lt;/a&gt; package should be
installed &lt;a class="footnote-reference" href="#footnote-1" id="footnote-reference-1"&gt;[1]&lt;/a&gt;. Using &lt;tt class="docutils literal"&gt;apt&lt;/tt&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ sudo apt install texlive-full
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, we can run the tools from &lt;tt class="docutils literal"&gt;texlive&lt;/tt&gt;, for example &lt;tt class="docutils literal"&gt;pdflatex&lt;/tt&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ pdflatex standaloneformula.tex
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This creates a PDF file that's useful for previews. To convert the &lt;tt class="docutils literal"&gt;.tex&lt;/tt&gt; file
to an image in SVG format, we'll use a two-step process:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ latex standaloneformula.tex

... generates standaloneformula.dvi

$ dvisvgm standaloneformula.dvi

... generates standaloneformula.svg
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If we want a PNG file instead of SVG:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ dvipng -D 300 standaloneformula.dvi
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;tt class="docutils literal"&gt;latexmk&lt;/tt&gt; tool can build a &lt;tt class="docutils literal"&gt;.tex&lt;/tt&gt; file into a PDF whenever the input
file changes, so running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ latexmk -pvc standaloneformula.tex
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And opening the PDF in a separate window, we can observe live refreshes of
edits without having to recompile explicitly. While useful in some scenarios,
I find that TeXstudio already does this well.&lt;/p&gt;
&lt;p&gt;The same tooling flow works for TikZ diagrams! A standalone LaTeX document
containing a single &lt;tt class="docutils literal"&gt;tikzpicture&lt;/tt&gt; element can also be rendered to a SVG or
PNG using the same exact commands.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="docker-versions"&gt;
&lt;h2&gt;Docker versions&lt;/h2&gt;
&lt;p&gt;If you'd rather not install all these tools directly but use Docker instead,
the &lt;tt class="docutils literal"&gt;texlive&lt;/tt&gt; image can be used to do the same things:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ docker pull texlive/texlive:latest
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And now we can use the same invocations, just through docker:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ docker run --rm -u $(id -u):$(id -g) \
    -v &amp;quot;$PWD&amp;quot;:/workdir -w /workdir texlive/texlive:latest \
    latex standaloneformula.tex

$ docker run --rm -u $(id -u):$(id -g) \
    -v &amp;quot;$PWD&amp;quot;:/workdir -w /workdir texlive/texlive:latest \
    dvisvgm standaloneformula.dvi
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="positioning-of-formulae-embedded-in-text"&gt;
&lt;h2&gt;Positioning of formulae embedded in text&lt;/h2&gt;
&lt;p&gt;When a formula like &lt;object class="valign-m7 latex-math" data="https://eli.thegreenplace.net/images/math/58d3c40cf29ef7230b9016e5b256cd8d9cdfb9c8.svg" style="height: 23px;" type="image/svg+xml"&gt;\frac{n+1}{n^2-1}&lt;/object&gt; is embedded in text, it should
be aligned properly to look good with the surrounding text. The information
required to do this is emitted by tools like &lt;tt class="docutils literal"&gt;dvisvgm&lt;/tt&gt; and &lt;tt class="docutils literal"&gt;dvipng&lt;/tt&gt;; for
example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ dvisvgm standaloneformula.dvi
pre-processing DVI file (format version 2)
processing page 1
  computing extents based on data set by preview package (version 14.0.6)
  width=81.267395pt, height=9.86894pt, depth=4.388947pt
  graphic size: 81.267395pt x 14.257887pt (28.562223mm x 5.011074mm)
  output written to standaloneformula.svg
1 of 1 page converted in 0.147623 seconds
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note the &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;height=...,&lt;/span&gt; &lt;span class="pre"&gt;depth=...&lt;/span&gt;&lt;/tt&gt; line in the output. The height is the total
height of the formula, and depth is its height below the &amp;quot;baseline&amp;quot; (how much
down it should stick out from the line). In my blog, these two are translated
to attributes on the image element embedding the SVG. Height is translated to
&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;style=&amp;quot;height:&lt;/span&gt; ...&lt;/tt&gt; and depth to &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;vertical-align:&lt;/span&gt; ...&lt;/tt&gt;.&lt;/p&gt;
&lt;hr class="docutils" /&gt;
&lt;table class="docutils footnote" frame="void" id="footnote-1" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#footnote-reference-1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;If the machine already has TeXstudio installed, &lt;tt class="docutils literal"&gt;texlive&lt;/tt&gt; is almost
certainly installed as well.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
</content><category term="misc"/><category term="Math"/><category term="Blogging"/><category term="Software &amp; Tools"/></entry><entry><title>Twenty years of blogging</title><link href="https://eli.thegreenplace.net/2023/twenty-years-of-blogging/" rel="alternate"/><published>2023-05-08T20:05:00-07:00</published><updated>2023-05-09T03:06:22.666145-07:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2023-05-08:/2023/twenty-years-of-blogging/</id><summary type="html">&lt;p&gt;This blog has now been running for &lt;a class="reference external" href="https://eli.thegreenplace.net/2003/05/06/why-start-a-weblog"&gt;20 years!&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Twenty years... a significant chunk of a human's adult life; while so
many things in my life have changed since May 2003, the blog has remained a
constant companion. This milestone inspired me to do some archaeology using the
amazing &lt;a class="reference external" href="https://archive.org/web/"&gt;Wayback …&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;This blog has now been running for &lt;a class="reference external" href="https://eli.thegreenplace.net/2003/05/06/why-start-a-weblog"&gt;20 years!&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Twenty years... a significant chunk of a human's adult life; while so
many things in my life have changed since May 2003, the blog has remained a
constant companion. This milestone inspired me to do some archaeology using the
amazing &lt;a class="reference external" href="https://archive.org/web/"&gt;Wayback Machine&lt;/a&gt;. It didn't have the very
first post, but I dug up one from just a week or so later - &lt;a class="reference external" href="https://eli.thegreenplace.net/2003/05/13/book-review-the-designers-guide-to-vhdl-by-p-ashenden"&gt;a book review&lt;/a&gt;.
Here's how it looked on &lt;a class="reference external" href="http://use.perl.org/~spur/journal/"&gt;http://use.perl.org/~spur/journal/&lt;/a&gt; (this link is long
dead, of course) in May 2003:&lt;/p&gt;
&lt;img alt="How this blog looked twenty years ago" class="align-center" src="https://eli.thegreenplace.net/images/2023/blog-twenty-years-ago.png" style="width: 500px;" /&gt;
&lt;p&gt;When I wrote an update at the &lt;a class="reference external" href="https://eli.thegreenplace.net/2013/05/06/ten-years-of-blogging"&gt;10 year mark&lt;/a&gt;, the blog
looked like this:&lt;/p&gt;
&lt;img alt="How this blog looked ten years ago" class="align-center" src="https://eli.thegreenplace.net/images/2023/blog-ten-years-ago.png" style="width: 500px;" /&gt;
&lt;p&gt;The looks - along with the hosting and the software used to generate and run the
blog - changed in &lt;a class="reference external" href="https://eli.thegreenplace.net/2014/blogging-setup-with-pelican/"&gt;September 2014&lt;/a&gt;, and the
blog has had roughly the current format ever since.&lt;/p&gt;
&lt;p&gt;I've made some adjustments to the infrastructure - comments outgrew their
usefulness and were &lt;a class="reference external" href="https://eli.thegreenplace.net/2018/turning-off-blog-comments/"&gt;turned off in 2018&lt;/a&gt;.
To further reduce dependencies on
third-party services and make the blog faster and more self-contained,
blog analytics were switched to use a lightweight self-hosted solution &lt;a class="reference external" href="https://eli.thegreenplace.net/2023/using-goatcounter-for-blog-analytics/"&gt;earlier
this year&lt;/a&gt;.
Some infrastructure changes and upgrades have been happening once in a while,
but these are completely transparent for readers. Otherwise, it's been going
pretty steady.&lt;/p&gt;
&lt;p&gt;Downtime has been exceedingly rare, and the blog's serving of static HTML
proved to be robust and resilient to spikes - including &lt;em&gt;many&lt;/em&gt; HN storms and
&amp;quot;hug of death&amp;quot; attempts. This is a great improvement from the previous
Wordpress-on-BlueHost approach, which struggled with uptime, especially in times
of load.&lt;/p&gt;
&lt;p&gt;The blog has been averaging ~25 posts per year in the past 10 years, with
something like 100,000 monthly visits. The content has shifted with
my interests, from a focus on C++ and Python to more Go content with a mix of
Rust and other new technologies like WebAssembly.&lt;/p&gt;
&lt;p&gt;As before, big thanks to all my dedicated readers. Reader feedback has always
been a highlight of the blogging experience. I have no intention of stopping,
but can this blog &lt;em&gt;really&lt;/em&gt; reach its 30th birthday? Only the future will tell.&lt;/p&gt;
</content><category term="misc"/><category term="Blogging"/><category term="Personal"/></entry><entry><title>Using GoatCounter for blog analytics</title><link href="https://eli.thegreenplace.net/2023/using-goatcounter-for-blog-analytics/" rel="alternate"/><published>2023-02-25T15:32:00-08:00</published><updated>2023-02-25T23:32:21.960380-08:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2023-02-25:/2023/using-goatcounter-for-blog-analytics/</id><summary type="html">&lt;p&gt;Ever since I switched this website &lt;a class="reference external" href="https://eli.thegreenplace.net/2014/blogging-setup-with-pelican/"&gt;to a static setup&lt;/a&gt; in 2014,
I've been trying to simplify it even more. In 2018 I turned off
&lt;a class="reference external" href="https://eli.thegreenplace.net/2018/turning-off-blog-comments/"&gt;Disqus comments&lt;/a&gt;,
eliminating a large source of latency.&lt;/p&gt;
&lt;p&gt;Recently, an additional effort to reduce dependencies and be more self-contained
led to the replacement of Google …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ever since I switched this website &lt;a class="reference external" href="https://eli.thegreenplace.net/2014/blogging-setup-with-pelican/"&gt;to a static setup&lt;/a&gt; in 2014,
I've been trying to simplify it even more. In 2018 I turned off
&lt;a class="reference external" href="https://eli.thegreenplace.net/2018/turning-off-blog-comments/"&gt;Disqus comments&lt;/a&gt;,
eliminating a large source of latency.&lt;/p&gt;
&lt;p&gt;Recently, an additional effort to reduce dependencies and be more self-contained
led to the replacement of Google Analytics by a self-hosted OSS analytics
solution. This post describes how I set up &lt;a class="reference external" href="https://github.com/arp242/goatcounter"&gt;GoatCounter&lt;/a&gt; to know how many people visit my
website over time, which pages are the most popular, and where visitors come
from (referer).&lt;/p&gt;
&lt;div class="section" id="choosing-goatcounter"&gt;
&lt;h2&gt;Choosing GoatCounter&lt;/h2&gt;
&lt;p&gt;When looking for an analytics solution, two categories of tools emerge pretty
quickly in the research:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Log parsers: these don't require the user's browser to make any additional
requests to log the visit; rather, they parse the web server's logs in the
background.&lt;/li&gt;
&lt;li&gt;Active analytics tools that inject some custom JS into every page;
your browser runs this JS, which typically makes a parameterized request
to another server to log the visit.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While log parsers have the attractive property of not requiring any additional
user interaction (they are &amp;quot;offline&amp;quot;, in a way), the requirement to muck with
my Apache server's logs extensively gave me pause. Since I'm interested in
historical logs often going back a year or more, it still requires some tool
running continually on my server, ingesting logs all the time and updating some
database. Overall, the process of setting this up didn't seem sufficiently
simple to me - but I may have well overlooked something. Suggestions are very
welcome!&lt;/p&gt;
&lt;p&gt;Of the multitude of analytics tools, GoatCounter stood out:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;Very privacy oriented, collecting so little data that a
&lt;a class="reference external" href="https://www.goatcounter.com/help/gdpr"&gt;GDPR notice isn't even required&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Light-weight; the added JS file is only 8 KiB and the server is
fast: 99.9% of requests are answered within ~2ms.&lt;/li&gt;
&lt;li&gt;Can be self-hosted, which both reduces the cost if I already run a
server and reduces dependencies.&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://github.com/arp242/goatcounter"&gt;OSS and written in Go&lt;/a&gt;.
This is not just a stylistic preference; since Go builds static binaries,
the &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt; tool is trivial to download and run. Much easier
deployment than, say, tools written in PHP.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div class="section" id="setting-up-goatcounter-for-my-website"&gt;
&lt;h2&gt;Setting up GoatCounter for my website&lt;/h2&gt;
&lt;p&gt;My GoatCounter setup is self-hosted; the &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt; server runs on the
same VPS as my blog, and serves at &lt;a class="reference external" href="https://stats.thegreenplace.net"&gt;https://stats.thegreenplace.net&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Since the &lt;tt class="docutils literal"&gt;thegreenplace.net&lt;/tt&gt; domain is served by Apache that listens on
ports 80 and 443 on the VPS, I needed to configure Apache to reverse-proxy
traffic for the &lt;tt class="docutils literal"&gt;stats&lt;/tt&gt; subdomain to &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt;. For a general
explanation of how to set up such proxying, see &lt;a class="reference external" href="https://eli.thegreenplace.net/2023/reverse-proxying-a-sub-domain-via-apache/"&gt;this earlier blog post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I started by downloading a pre-built &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt; executable from the
&lt;a class="reference external" href="https://github.com/arp242/goatcounter/releases"&gt;releases page&lt;/a&gt;, and then
unzipping it in some directory &lt;tt class="docutils literal"&gt;$GOATDIR&lt;/tt&gt;. Then ask it to create a new
SQLite DB:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ ./goatcounter-v2.4.1-linux-amd64 db -createdb create site \
      -vhost=stats.thegreenplace.net -email=eliben@gmail.com
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This creates &lt;tt class="docutils literal"&gt;$GOATDIR/db/goatcounter.sqlite3&lt;/tt&gt;. Next, run the server itself:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ ./goatcounter-v2.4.1-linux-amd64 serve \
      db sqlite3+$GOATDIR/db/goatcounter.sqlite3 \
      -listen 127.0.0.1:5000 -tls http
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt; server listens on local port 5000, which is not exposed
outside the VPS. Following the instructions of the aforementioned blog post,
Apache can then be set up to forward traffic for the &lt;tt class="docutils literal"&gt;stats&lt;/tt&gt; subdomain to this
port.&lt;/p&gt;
&lt;p&gt;If all works well, the &lt;tt class="docutils literal"&gt;stats&lt;/tt&gt; subdomain should be accessible now.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="restarts-and-automatic-backups"&gt;
&lt;h2&gt;Restarts and automatic backups&lt;/h2&gt;
&lt;p&gt;If the VPS reboots, I don't want to restart the &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt; server manually.
Therefore, it has to be set up as a service, by adding a new systemd
configuration file at &lt;tt class="docutils literal"&gt;/etc/systemd/system/goatcounter.service&lt;/tt&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;# /etc/systemd/system/goatcounter.service
# Description of what the program does
[Unit]
Description=GoatCounter

[Service]
Type=simple
# If anything unexpected happens, Systemd will try to restart the program
Restart=always
# We need to send the absolute path of the database to GoatCounter.
ExecStart=$GOATDIR/goatcounter-v2.4.1-linux-amd64 serve -db sqlite3+$GOATDIR/db/goatcounter.sqlite3 -listen 127.0.0.1:5000 -tls http

[Install]
WantedBy=multi-user.target
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And then the service can be started using &lt;tt class="docutils literal"&gt;systemctl&lt;/tt&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ sudo systemctl start goatcounter
$ sudo systemctl status goatcounter
● goatcounter.service - GoatCounter
     Loaded: loaded (/etc/systemd/system/goatcounter.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-02-16 14:04:20 UTC; 1 week 1 day ago
   Main PID: 732 (goatcounter-v2.)
      Tasks: 16 (limit: 2324)
     Memory: 135.9M
        CPU: 15min 156ms
...
...
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, &lt;tt class="docutils literal"&gt;systemctl&lt;/tt&gt; can be told to automatically run this service at startup:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ sudo systemctl enable goatcounter
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After clicking around the website for a bit, one will be able to observe that
GoatCounter's DB file is being updated. This is just a SQLite database, so it
can be explored using the command-line &lt;tt class="docutils literal"&gt;sqlite3&lt;/tt&gt; tool; something like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;sqlite&amp;gt; select * from hits order by created_at desc limit 10;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Make sure to back the DB up somewhere; I have a cron job that performs a
backup to cloud storage; this can be accomplished by first asking SQLite to dump
a backup file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ sqlite3 goatcounter.sqlite3 &amp;quot;.backup $BKPFILE&amp;quot;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With any custom filename as &lt;tt class="docutils literal"&gt;$BKPFILE&lt;/tt&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="using-goatcounter"&gt;
&lt;h2&gt;Using GoatCounter&lt;/h2&gt;
&lt;p&gt;Once GoatCounter is set up and running, it's pretty easy to use. Log into its
dashboard and poke around; the dashboard looks something like:&lt;/p&gt;
&lt;img alt="Screenshot showing a sample of how the GoatCounter dashboard looks" class="align-center" src="https://eli.thegreenplace.net/images/2023/goatcounter-screenshot.png" /&gt;
&lt;p&gt;Clicking on &lt;em&gt;Help&lt;/em&gt; on the top right leads one to a nice documentation site with
lots of useful usage information. GoatCounter has &lt;em&gt;many&lt;/em&gt; features; for example,
if you prefer working with the command-line, the &lt;tt class="docutils literal"&gt;goatcounter&lt;/tt&gt; binary (the
same one that acts as a server) has a &lt;tt class="docutils literal"&gt;dashboard&lt;/tt&gt; command that will render
a dashboard to the terminal.&lt;/p&gt;
&lt;p&gt;A feature I like a lot is &lt;a class="reference external" href="https://www.goatcounter.com/help/api"&gt;the API&lt;/a&gt;,
with a &lt;a class="reference external" href="https://www.goatcounter.com/api2.html"&gt;detailed reference available&lt;/a&gt;.
This can be used to programmatically query your GoatCounter instance for all
kinds of aggregates and statistics. For example, to figure out which pages on
my website were the most popular during 2022, I can run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ curl -X GET &amp;#39;https://stats.thegreenplace.net/api/v0/stats/hits?start=2022-01-01&amp;amp;end=2022-12-31&amp;amp;daily=1&amp;#39; \
  -H &amp;#39;Content-Type: application/json&amp;#39; \
  -H &amp;#39;Authorization: Bearer &amp;lt;TOKEN-HERE&amp;gt;&amp;#39;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;(after generating an API token through the web dashboard).&lt;/p&gt;
&lt;p&gt;This dumps a JSON file with the data, which can be easily analyzed by a program.&lt;/p&gt;
&lt;/div&gt;
</content><category term="misc"/><category term="Blogging"/></entry><entry><title>Turning off blog comments</title><link href="https://eli.thegreenplace.net/2018/turning-off-blog-comments/" rel="alternate"/><published>2018-02-13T05:30:00-08:00</published><updated>2023-02-04T13:41:52.184304-08:00</updated><author><name>Eli Bendersky</name></author><id>tag:eli.thegreenplace.net,2018-02-13:/2018/turning-off-blog-comments/</id><summary type="html">&lt;p&gt;Since switching to the &lt;a class="reference external" href="https://eli.thegreenplace.net/2014/goodbye-wordpress-a-new-blog/"&gt;new statically-generated blog&lt;/a&gt;,
dealing with comments has been a continuous dilemma. On one hand, I wanted to
retain comments since it provides readers an immediate opportunity to respond,
suggest errors or additional material, etc. On the other hand, comments are - by
nature - dynamically generated, and it …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Since switching to the &lt;a class="reference external" href="https://eli.thegreenplace.net/2014/goodbye-wordpress-a-new-blog/"&gt;new statically-generated blog&lt;/a&gt;,
dealing with comments has been a continuous dilemma. On one hand, I wanted to
retain comments since it provides readers an immediate opportunity to respond,
suggest errors or additional material, etc. On the other hand, comments are - by
nature - dynamically generated, and it felt bad adding heavy Disqus JS to my
otherwise static site.&lt;/p&gt;
&lt;p&gt;And indeed, over the years I've heard some complains that my blog is sluggish.
Wait, what? This makes little sense - I'm not on Wordpress any more; I simply
serve static HTML pages; oh wait, Disqus...&lt;/p&gt;
&lt;p&gt;There were other concerns.&lt;/p&gt;
&lt;p&gt;First, whether comments are useful any more, at all. I've noticed that some of
my most popular posts generated hundreds of comments in Reddit and HN
discussions, but only a handful on the site. Why is that? I think the answer
is clear - folks who have Reddit and HN accounts have recognizable user names
there and any content helps their reputation. It's also a single place to
collect all your comments - on all blogs - rather than it being at the mercy of
the blog owner. I've also been receiving about a similar amount of comments by
plain email, and recently Twitter too.&lt;/p&gt;
&lt;p&gt;Second, Disqus has to pay the bills somehow, and I wasn't using their paid
package. It's not that it's very expensive, but paying as much for the comments
as I'm paying for the VM running this blog (along with some other things) just
feels wasteful. Moreover, since I've been resisting the idea of monetizing the
blog, something feels off about paying for multiple services just to run it.&lt;/p&gt;
&lt;p&gt;As expected, when you're not paying - you're the product. Disqus is injecting
ads in their comments section, and not ads of the good kind. Not stuff relevant
to my blog readers, but the terrible crap so common online recently - &amp;quot;man sheds
25 pounds by eating this fruit; doctors are shocked&amp;quot;, &amp;quot;Oakland mom can't believe
her son's transformation&amp;quot; and so on.&lt;/p&gt;
&lt;p&gt;I've been disabling these through Disqus's control panel, but after a while they
reappear - without any notification. I'm sure Disqus is acting within their TOS,
and I'm not blaming them, but this is no longer working for me. The energy spent
on tracking this would be better used by writing more blog posts.&lt;/p&gt;
&lt;p&gt;Therefore, I'll be disabling all comments on the blog. Instead, I'll provide a
direct link to my email and Twitter accounts. In addition, most of my posts get
to Reddit and HN fairly quickly and I usually try to follow the discussions that
ensue, so feel free to comment there.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update (2023-01-09):&lt;/strong&gt; I was reflecting on this change recently.
This has turned out to be a great decision I do not regret making.&lt;/p&gt;
</content><category term="misc"/><category term="Blogging"/></entry></feed>