Terminal Graphics #

Last updated March 17, 2026
circuitpythonjavascript

The terminalio.Terminal class implements a traditional 'terminal' with VT100 control codes. It does this by giving you a stream you can print to. It converts the stream of characters into a tilegrid using the bitmap font. It will wrap lines if necessary. Unfortunately it only supports a single color at a time. Multi-colored text isn't supported.

import terminalio
import displayio

# size of each font glyph (this is a monospaced font)
fontx, fonty = terminalio.FONT.get_bounding_box()

# adjust palette if desired
plain_palette = displayio.Palette(2)
plain_palette[0] = 0x000000
plain_palette[1] = 0x33ff33

# create grid using the font 
# width and height in tiles
# x and y in pixels
pgrid = displayio.TileGrid(terminalio.FONT.bitmap,
                           x=0,
                           y=0,
                           width=display.width // fontx,
                           height=display.height // fonty,
                           tile_width=fontx,
                           tile_height=fonty,
                           pixel_shader=plain_palette)

# terminal attached to the tilegrid
ptermx = terminalio.Terminal(pgrid, terminalio.FONT)

# add to the screen
display.root_group.append(pgrid)

Print to the terminal with print:

# with newline
print("some text", file=ptermx, end="\r\n")

# without newline
print("some text", file=ptermx, end="")

create a new project with Vite #

Last updated March 11, 2026
javascriptvite

The create-react-app tool is deprecated. For a similar experience I use Vite.

Build a new react + typescript project with create and follow the prompts.

npm create vite@latest react-ts my-app-name -- --template react-ts

Callbacks when the browser goes on or offline #

Last updated March 11, 2026
domjavascript

Get callbacks when the browser goes on or offline:

const hand_online = () => {
    console.log('we are online')
}
const hand_offline = () => {
    console.log('we are offline')
}
window.addEventListener("online", hand_online)
window.addEventListener("offline", hand_offline)

npx #

Last updated March 11, 2026
javascriptnpm

npx lets you create a command line tool that can be run without already having it installed. To turn your npm module into such a command give it should have a javascript file with a shebang line like this: #!/usr/bin/env node. This can be in your Typescript file and the compiler should make sure it ends up in the final output js file.

Then in your package.json file needs a bin entry pointing to the script like this:

{
  "bin": {
    "amx": "build/cli.js"
  }
}

Now publish your module and run it from another shell with npx -g modulename

Run NPM script in a different dir #

Last updated March 11, 2026
javascriptnpm

You can run an npm script from a different directory by using the --prefix parameter

npm --prefix <path> run <command>

clean NPM cache #

Last updated March 11, 2026
npmjavascript

When you have just released a new package version and npm install in another project says the package doesn’t exist, that could be because it tried to fetch the package before it was really live on npmjs.org. The problem is that it then remembers this forever. So you need to clear out the cache with

npm cache clean --force