Skip to content

Instantly share code, notes, and snippets.

@george-hawkins
george-hawkins / arm64.md
Last active March 24, 2024 14:36
Running virtualized x86_64 and emulated arm64 Ubuntu cloud images using QEMU

QEMU arm64 cloud server emulation

This is basically a rehash of an original post on CNXSoft - all credit (particularly for the Virtio device arguments used below) belongs to the author of that piece.

Download the latest uefi1.img image. E.g. ubuntu-16.04-server-cloudimg-arm64-uefi1.img from https://cloud-images.ubuntu.com/releases/16.04/release/

Download the UEFI firmware image QEMU_EFI.fd from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/

Determine your current username and get your current ssh public key:

@george-hawkins
george-hawkins / wake-issue.md
Last active March 9, 2024 19:35
After installing Ubuntu 20.04 my machine frequently wakes from sleep for no obvious reason. This gist describes my attempts to resolve this.

Diagnosing spurious wakes

This gist documents my attempts to get to the bottom of spurious wakes after installing Ubuntu 20.04 LTS on my system.

Initially, I thought it might be another system on my network sending Wake-on-LAN (WoL) packets. Then I thought it might be a known XHCI spurious wake kernel issue. And lastly, I finally resolved things by actively disabling the ability of USB devices, e.g. the mouse, to wake the system.

Update: I later came up with a better way of disabling wake-on-mouse that's covered here.

Note: as one of these steps, I upgraded the system BIOS - while this didn't resolve this particular issue, it did resolve an annoying issue with the graphic state not being properly restored for certain applications after wake-up.

@george-hawkins
george-hawkins / serial_tester.py
Created March 2, 2024 15:33
Code accompanying function call overhead question on MicroPython forums
import argparse
import statistics
import time
import zlib
import serial
TIMESTAMP_BYTE_COUNT = 8
CRC_BYTE_COUNT = 4
@george-hawkins
george-hawkins / yield-example.py
Created February 25, 2024 14:29
Working with `yield` in Python
def foo():
for i in range(0, 16):
print(f"> {i}")
j = yield i
print(f"> {j}")
yield j
print(f"* 1")
gen = foo()
@george-hawkins
george-hawkins / README.md
Last active January 27, 2024 15:05
Forcing GitHub to reindex your repos

Forcing GitHub to reindex your repos

Apparently, GitHub stops indexing repos that have not had a commit for over a year. They say this is to ensure that search limits itself to providing the most relevant results.

But this is a pain if you know your own repos contain some particular information but GitHub turns up no search results because of this constraint.

A way to force a reindex of a repo is to search it - you may get no results but GitHub will put the repo in a queue to be reindexed and in about 5 minutes the same search may produce a result if the repo contains the relevant term.

However, if you don't know the relevant repo and want to search all your repos, it's somewhat inconvenient to have to manually search them all to force a reindex.

BLE Nano and the nRF51822 SDK

If you've tried using the nRF51822 SDK with the BLE Nano (after following the RedBearLab guide) you may have come to a dead end.

Even the simplest examples didn't work for me. I assumed I had a dead Nano (despite the upload process seeming to work fine).

The reason turned out to be that the latest SDK versions assume you have a nRF51822 chip with 32KB of RAM rather than the 16KB that the nRF51822 on the Nano has.

James Willcox explains this in a post to the RedBearLab BLE Nano support forum.

@george-hawkins
george-hawkins / README.md
Last active April 18, 2023 20:02
Turn off HP Omen desktop lighting

Turn off HP Omen desktop lighting

To turn To turn off case lighting go to the Microsoft Store, search for and install OMEN Gaming Hub.

There's no need for any of the secondary installs that it tries to trigger - i.e. Light Studio and HP System Event Utility.

Open OMEN Gaming Hub - ignore any attempt to make you sign-in or register for an account.

Ignore Light Studio, click OMEN Desktop and select the Lighting tab.

pyenv update
pyenv install -l
pyenv install 3.10.8
pyenv global 3.10.8

Show CUDA version:

This page describes the flow of requests, tokens etc. when using the Okta sign-in widget with a backend (such as Spring Boot) that's configured for OAuth2 based authentication.

Okta Login flow

If I have a web-app running on myapp.mycompany.com and an Okta organization running on dev-993392.oktapreview.com then there are 3 actors involved in the login flow:

  • The server that serves up the myapp.mycompany.com pages.
  • Browser pages with origin myapp.mycompany.com.
  • Browser pages with origin dev-993392.oktapreview.com