Skip to content

Instantly share code, notes, and snippets.

@andrewn
andrewn / .zshrc
Created October 9, 2024 09:44
mise (formally rtx) auto-switch version
function node_prompt_info() {
mise current 2>/dev/null
}
# https://johnlindquist.com/automatically-switch-node-versions-based-on-your-packagejson-and-precmd-in-zsh/
# https://chat.openai.com/share/fbe51310-cde1-47fe-9d6c-f1d1ac017008
# https://chat.openai.com/share/6bfa3691-de5e-44ba-bd18-0274f69a5fdf
precmd(){
if [ -f package.json ]
@andrewn
andrewn / kill-port
Created May 16, 2022 12:12
Find out what's using those local TCP ports
#!/bin/bash
# Kill process using the port
# Usage: kill-port <port-number>
#
# Example:
# $ kill-port 3000
# Killed 🔪
if [ $# -eq 0 ]
then
@andrewn
andrewn / espruino.js
Created February 14, 2021 10:34
Corona Ampel-Status for Espruino and LEDs
var config = {
"ssid": "WIFI SSID",
"password": "WIFI PASSWORD",
"dataURL": "http://ampel-status.netlify.app/.netlify/functions/hello_fetch",
"timeoutMs": 60 * 1000,
"numLEDs": 3,
};
var errors = [];
var currentErrorIndex = 0;
@andrewn
andrewn / script.js
Created April 18, 2018 12:24
wjvexp
var Engine = Matter.Engine,
Render = Matter.Render,
Runner = Matter.Runner,
Events = Matter.Events,
MouseConstraint = Matter.MouseConstraint,
Mouse = Matter.Mouse,
World = Matter.World,
Bodies = Matter.Bodies;
// create engine
@andrewn
andrewn / instructions.md
Last active February 27, 2018 17:08
[DO NOT USE] Local speech with neue radiodan

⚠️ These instruction are out-of-date, do not use ⚠️

To get local speech running, you should install simon-say which is an equivalent of speech-dispatcher that uses the macOS say command to speak.

npm install --global https://github.com/andrewn/simon-say/archive/master.tar.gz

Make sure you have the latest radiodan and run the radiodan manager:

cd ~/path/to/radiodan/services/manager

npm start

@andrewn
andrewn / INSTALL.md
Last active February 13, 2018 13:46
Pi text-to-speech (TTS)

speechd is a wrapper around tts systems festival is the thing that speaks

sudo apt-get install speech-dispatcher festival -y

See which voices are available:

spd-say --list-synthesis-voices

Say something:

@andrewn
andrewn / install.md
Last active February 26, 2018 11:32
Radiodan: Configure PulseAudio speaker and microphone
  • Raspbian Lite
  • Create /Volumes/boot/ssh
  • Write wi-fi config to /Volumes/boot/wpa_supplicant.conf

Shell into Pi:

sudo apt-get install git -y

git clone https://github.com/respeaker/seeed-voicecard.git

cd seeed-voicecard

@andrewn
andrewn / README.md
Created January 26, 2018 11:35
Do something when Pi's being being ping'd
@andrewn
andrewn / electronics.md
Last active December 11, 2017 17:44
Electronics kit

Basics

For a basic no-UI Radiodan you probably want:

  • microSD cards
  • some way of writing the microSD cards
  • Raspberry Pi 3
  • Micro USB (data + power)
  • PhatDAC or a good USB sound card
  • Powered speaker
@andrewn
andrewn / instructions.md
Last active June 1, 2024 12:41
Testing SSL (LetsEncrypt certificate and loopback domain)

Testing SSL (LetsEncrypt certificate and loopback domain)

General approach

This sets up a publically-available domain that loops back to localhost IP address 127.0.0.1. For example, this address could be localhost.example.com if we controlled the example.com domain. This relies on having a public domain name whose DNS records you can control. We can then generate LetsEncrypt certificates for this domain.

Our HTTP server runs on localhost:80 (default HTTP port). This lets us visit http://localhost.example.com in a web browser and see the server running on localhost:80.

We then run an HTTPS proxy server on localhost:443 (default HTTPS port) that uses the LetsEncrypt certificates we generated for localhost.example.com. Visiting https://localhost.example.com hits the proxy, which returns the correct certificates meaning the browser displays the "Secure" message. The proxy then passes the request through to the HTTP server.