Skip to content

Instantly share code, notes, and snippets.

@stonehippo
stonehippo / nodejs_raspberry_pi.md
Last active April 18, 2024 15:04
Methods for installing Node.js on Raspberry Pi

Setting Up Node.js On Raspberry Pi

There are several ways that you can set up Node.js on a Raspberry Pi when running Raspbian/Rapberry Pi OS. Depending on your needs, the version of the RPi that you're using, and how you like to manage installs, you have a lot of options.

Node.js from source

Do not do this if you can avoid it, it's super slow. If you insist on doing it and have the time, you can start at https://nodejs.org. But really, don't do this.

If you have tons of time on your hands, don't need Node anytime soon, and insist on building from source for some reason, here's a guide you can try out that covers building Node.js on an ARMv6 Raspberry Pi.

Side note: unless you have a need for the latest and greatest features, I recommend developing using the most recent Long Term Support (LTS) version of Node available, especially for anything you plan to put into production for any length of time.

@stonehippo
stonehippo / install_ruby_with_rbenv.md
Last active April 6, 2024 23:44
Installing a new Ruby with rbenv on Mac OS

Install a new Ruby with rbenv on Mac OS (and make yourself a superhero)

If you're doing stuff with Ruby on a Mac, e.g. installling Jekyll or something, by default you'll end up having to use the sudo command to do stuff, since the permission to modify the default config is not available to your user account.

This sucks and should be avoided. Here's how to fix that.

Installing a new Ruby

To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*

A word of warning: you will have to use Terminal to install this stuff. If you are uncomfortable with text, words, and doing stuff with your computer beyond pointing and hoping, this may not work well for you. But if that's the case, I'm not sure why you were trying to use Ruby in the first place.

@stonehippo
stonehippo / BLE-programming-Raspberry-Pi.md
Last active March 23, 2024 21:35
Bluetooth LE Programming On Raspberry Pi

Bluetooth LE Programming On Raspberry Pi

I'm looking at building up some Bluetooth LE programming expertise on Linux, specifically for use with Raspberry Pi 3 B+ and Pi Zero W models.

This is a compendium of libraries and tools that I'm looking at to build that skill on.

DON'T FORGET!!!

On the Raspberry Pi Zero W, a user must be a member of the bluetooth group to work with tools like bluetoothctl. Set this up with:

@stonehippo
stonehippo / wio_terminal_cricuitpython_rtl_support_notes.md
Last active March 6, 2024 13:22
Working notes for getting Seeed WIO Terminal WiFi & BLE working with CircuitPython

CircuitPython support for WiFi and Bluetooth LE on Seeed WIO Terminal

Context

The Seeed WIO Terminal is generally supported by CircuitPython, but there is no implementation for access to the WiFi or Bluetooth LE networking functions on the board. After taking a look at the Arduino support for these features, I can see that the RealTek RTL8720D is set up to be driven by a UART connection from the SAMD51 that acts as the main controller for the WIO Terminal. In other words, the RTL8720D is set up as a co-processor, similar to the ESP32 in Adafruit's Airlift modules.

The UART driver is based on an embedded remote procedure call (eRPC) library on the Arduino side. This is good news, because it means that there is a chance that the driver can be implemented in CP! In theory, this can be built o

@stonehippo
stonehippo / language_installers.md
Last active February 24, 2024 02:39
Programming language version managers

Programming language version managers

Keeping up to date with a program language installation isn't always easy. In particular, juggling the latest and greatest,legacy versions needed to maintain compatibility, keeping several versions of a langauge installed, or needing admin acess can be a real pain. The package manager included with your operating system, such as dpkg/apt or yum might help somewhat, but they usually cannnot handle multiple versions, typically want you to be an admin, and often do not have the most recent version available in their repos.

So what's an enterprising dev to do?

One answer is to install a dedicted tool for installing a managing a program language. These tools operate a bit like a language-specific package manager, with tools for installing, managing and swapping versions of a language. They operate by adjusting your path, often via a 'shim' pointing to a local install. They typically leave your system-installed versions alone. All in all, these tools are a huge boon

@stonehippo
stonehippo / homekit_dev.md
Last active February 19, 2024 20:47
Some resource for developing Apple Homekit stuff

Homekit Dev

An ongoing list of resources for developing Apple Homekit stuff

Apple Documentation

implementations

@stonehippo
stonehippo / wio-terminal-circuitpython.md
Last active February 13, 2024 13:32
Using CircuitPython modules to work with the Seeed Wio Terminal

Seeed Wio Terminal Circuitpython Modules

note: All of these examples have been tested with the latest version of CircuitPython, which as of this writing was 7.2.4. Some of these examples may require tweaks in older or later versions, due to change in the drivers.

The Seeed Wio Terminal is a nifty connected device development kit. Built around a SAMD51 Cortex-M4 microcontroller and a Realtek RTL8720DN for WiFi and Bluetooth, plus an integrated display and a collection of handy sensors, the Wio Terminal is a great platform for IoT and smart device development.

One of the nice things about the Wio Terminal is the number of options available for developement platforms. You can choose the long-time hardware hacking favorite Arudino, MicroPython or Ardupy, an interesting blend of MicroPython and Arduino. And there's support for my

@stonehippo
stonehippo / docker_usb_guest_osx.md
Last active January 3, 2024 21:18
Getting a USB device to show up in a Docker container on OS X

Getting a USB device to show up in a Docker container on OS X

Some background

I was trying to get the Arduino IDE to work inside a Docker container on OS X. I was able to get the IDE working (see Getting X11 GUI applications to work on OS X with Docker), but I could not figure out how to make the USB port for the Arduino visible.

The solution

I first tried to directly map hardware serial port into the Docker container, doing something like this:

@stonehippo
stonehippo / README.md
Last active December 29, 2023 00:49
Making a little dice roller in modern Python

A tiny dice roller in modern Python

I have been reading Fluent Python, and I can tell that it's going to help me be a better Python coder right away.

A while ago, I started a Javascript library for rolling common dice types, which I intended to use for various games. While reading Fluent Python, I realized that I could write the same logic in a much more compact form, thanks to listcomps, generator functions, and unpacking. In fact, the core implementation takes only four lines of code:

sides = [4, 6, 8, 10, 12, 20]
d4, d6, d8, d10, d12, d20 = [range(1, count + 1) for count in sides]
@stonehippo
stonehippo / RGB_strip_control.py
Created November 16, 2023 15:30
Some CircuitPython to control an RGBW LED strip.
"""
Simple CircuitPython control of an RGB strip via Mosfetti or plain MOSFETS.
Copyright (c) 2023 George White <stonehippo@gmail.com>
Written for the Adafruit Metro M0, but will work with any board with
4 PWM-capable pins.
"""
import board
from pwmio import PWMOut