Skip to content

Blog

Trailing Whitespace

One of the most frustrating things to deal with is the trailing space. Trailing spaces are such a pain because

  • They can screw up string literals
  • They can break expectations in a text editor (i.e. jumping to a new line or the end of the line)
  • They can actually break programming languages
  • They are just unflattering

However, in Vim, it takes one autocmd to alleviate this.

augroup spaces
autocmd!
autocmd BufWritePre \* %s/s+$//e
augroup END

On every buffer save substitute spaces at the end of the line with nothing. Easy!

Mercedes-Benz NTG5 STAR2

Fully integrated high-end multimedia system with 6-disc DVD changer, hard-drive navigation system, internet browser, telephony plus DVD video and Music Register, shown on high-resolution 21.3 cm colour TFT display.

The NTG Star2 is a mid-2010s Mercedes-Benz in‑car navigation/infotainment system (part of the COMAND/Audio20 series). In practice it was the NTG5‑generation system used in models like the W205 C‑Class, W222 S‑Class, GLC, etc. For audio and navigation it typically used the standard 7″ (17.8 cm) TFT display and console controller. Importantly, NTG Star2 used Garmin’s “Map Pilot” technology for GPS navigation in Audio20-equipped cars – inserting a Garmin SD‑card lets the Audio20 unit run 3D maps and routing​. (The COMAND head unit itself was Mercedes-made, but Garmin supplied the map/database software.)

NTG Star2 debuted around 2014–2015 as the successor to the NTG4.5 COMAND system. Mercedes introduced it on new models (for example, the 2015–2020 C‑Class W205 and later E‑Class and GLC) as COMAND Online (NTG5) hardware​. These NTG5/Star2 units featured a built‑in hard drive for media and optional CD/DVD storage. Around 2018–2019 Mercedes began updating Star2 to a new software version called “Star1” (this was essentially a software revision to enable features like Apple CarPlay). As one forum noted, “my new [head unit] is called NTG Star1 and CarPlay works – the old one was NTG Star2”​. (In other words, Star2 was the original NTG5 software on older Audio20 hardware; Star1 was the newer update with smartphone integration.)

Today NTG Star2 systems remain supported through Mercedes accessories and parts. Mercedes still sells Garmin Map Pilot SD navigation cards and software updates for NTG5/Star2 systems​. For vehicles that came with NTG Star2, a dealer or owner can purchase official updates (e.g. Europe 2020/2021 map packs) for the Garmin Map Pilot. Mercedes also offered an accessory COMAND Online head unit upgrade with DVD changer – a high-end multimedia unit with a 6‑disc changer and hard‑drive nav that replaces the original unit. In short, the NTG Star2 system remains available on its original models (C‑Class, S‑Class, etc.) and can be serviced or upgraded using genuine Mercedes parts (for example, the COMAND Online unit with DVD changer or Garmin Map Pilot module)​.

While Mercedes-Benz designed the NTG Star2 hardware and user interface, Garmin’s involvement was confined to the navigation content. On Audio20/NTG5 Star2 cars, Garmin supplied the Map Pilot navigation module (SD card and software) that plugs into the Mercedes system​. There is no ongoing Garmin development of NTG Star2 itself – Garmin’s input was the map database and guidance engine. All system updates (DVD/DVD changer upgrades or map updates) are handled through Mercedes-Benz parts (including Garmin-branded map cards sold by Mercedes).


More Mercedes - Technical Accessories and Collection Products from Mercedes-Benz
More Mercedes - Technical Accessories and Collection Products from Mercedes-Benz

Avoiding eqnarray

Since reading about its faults in The Not So Short Introduction to LaTeX (highly recommended read), I've avidly stayed away from eqnarray. However, I don't think the book conveys the ideas as well as it should. Its suggestion was IEEEeqnarray, as opposed to the classically recommended align. This article from the TeX Users Group conveys them more eloquently and provides better alternatives.

latexerr

The most frustrating thing about compiling LaTeX in a terminal is the wall of text that gets written to stdout. An easy solution would be piping to /dev/null—except then you wouldn't be able to get error messages (even if you only pipe stdout to /dev/null and keep stderr). So, I made a solution that handles compiling by piping error messages to less. The syntax latexerr FILENAME will compile the file. Passing --clean will delete temporary LaTeX files.

#!/bin/bash

# USAGE: ./script FILE --clean --glossary

extensions_to_delete=(\
	gz fls fdb_latexmk blg bbl log\
    aux out nav toc snm glg glo xdy
)

compile_and_open() {
    argument="$1"
    auxname="${argument%.tex}.aux"
    errors=$(pdflatex -shell-escape \
        -interaction=nonstopmode \
        -file-line-error "$argument" | \
        grep ".*:[0-9]*:.*")

    if [[ -n $errors ]]; then
        echo "$1 Errors Detected"
        echo "$errors" | less
    else
        open_file $1
        echo "$1 Compile Successful"
    fi
}

open_file() {
    filename=`echo "$1" | cut -d'.' -f1`
    open "$filename.pdf"
    echo "$filename Opened"
}

# http://tex.stackexchange.com/questions/6845/compile-latex-with-bibtex-and-glossaries
glossary() {
    compile $1
    makeglossaries $1
    compile $1
    compile $1
}

clean() {
    for file in $(dirname $1)/*; do
        filename=$(basename "$file")
        extension="${filename##*.}"
        filename="${filename%.*}"

        for bad_extensions in "${extensions_to_delete[@]}" ; do
            if [[ $bad_extensions = $extension ]]; then
                rm $file
                echo "$file Deleted"
            fi
        done
    done
}

main() {
    compile_and_open $1

    if [ "$3" = "--glossary" ]; then
       glossary $1
    fi

    if [ "$2" = "--clean" ]; then
        clean $1
    fi

}

main "$@"

Painting Gabriel’s Horn

A horn you can fill with paint, but you can't paint the surface.

Mathematics is full of wonderful things, but nothing strikes me as more wonderful—or more unintuitive—than Gabriel's Horn.

Here's how it works: take the function \(y = \frac{1}{x}\) where \(x \in \mathbb{R}^+, 1 \leq x \leq \infty\), and rotate it around the \(x\) axis. Not too hard to picture—it looks like a horn. But here's where it gets weird.

Let's calculate the volume. Using solids of revolution, we can show:

$$
V = \pi \lim_{t \rightarrow \infty} \int _1 ^t \frac{1}{x^2} dx = \pi \lim _{t \rightarrow \infty} ( 1 - \frac{1}{t} ) = \pi
$$

Simple, elegant. The volume is exactly \(\pi\). Now let's check the surface area.

We know the general definition of arc length is \(\int _a ^b \sqrt{1 + f'(x)^2}\). Combining this with our solids of revolution gives us:

$$
A = 2\pi \lim _{t \rightarrow \infty} \int _1 ^t \frac{1}{x} \sqrt{1 + \left( -\frac{1}{x^2} \right)^2 } dx
$$

This integral isn't trivial, but there's a trick. Take the simpler integral $$2\pi \lim _{t \rightarrow \infty} \int _1 ^t \frac{dx}{x}$$ instead. This will always be less than or equal to our original integral (we dropped the \(\sqrt{1 + (-\frac{1}{x^2})^2}\) term, which is always ≥ 1). Evaluating this simpler integral:

$$
A \geq 2\pi \lim _{t \rightarrow \infty} \int _1 ^t \frac{dx}{x} \implies A \geq \lim _{t \rightarrow \infty} 2\pi \ln(t)
$$

Wait. It diverges. The volume is \(V = \pi\), but the surface area is \(A \geq \infty\). This isn't a mistake—the math checks out. And that's simply wonderful.

A horn you can fill with paint, but you can't paint the surface.