List processes currently using swap space (BASH)

When trying to work out where all your RAM went, it's sometimes useful to be able to take a look at what currently has pages in swap.

It's worth bearing in mind, though, that processes listed aren't necessarily the root cause - they may well have been paged out to free up RAM for some other process

Read more…

Boost Heating Temperature for 30 minutes (HomeAssistant)

Initially roughly patched together in Musings on Home Automation this script is intended to work around the fact that Google's NEST Thermostat doesn't have a "boost" function - making it a bit tricky if you want a part of the house not containing the NEST thermostat to be able to call for heat.

The basic idea is that it will increase the NEST target temperature by a configurable amount for 30 minutes, causing the boiler to come on if it was off.

So that the script can track state, you need to create a number input with ID current_heating_target and another with ID heating_boost_degrees (set it to 5)

Read more…

Turn light up 50% on button press, then full, then off (HomeAssistant)

We've a wall light in our hall whose main lightswitch is poorly placed. So, I put a smart bulb in and put a Zigbee button in a more convenient place.

However, the light is brighter than a thousand suns, so I wanted a it to come on at just under half brightness by default, with an option to turn it up to full (in case someone loses a contact, or is bored of having retinas)

The following script in HomeAssistant/Hass.io achieves that.

One of the things that an trip you up, is checking the current brightness state - it's not reported as a percentage, but as a (I assume) byte value.

Read more…

Racadm: Enable Read ahead on disks on a Dell RAID controller (Misc)

Just occasionally, you'll be looking into performance issues and find that, for some reason, someone has disabled read-ahead when creating virtual disks in the raid controller.

Dell's documentation tells you how to modify this in such an obscure and obfuscated way that it's almost a match for HP's server documentation.

This snippet details how to change read-ahead for disks on a Dell RAID controller using racadm

Read more…

Connect to HTTPS upstream with lua-resty-http (LUA)

The lua-resty-http is incredbily useful when you need some LUA in OpenResty to place external HTTP requests.

However, when you need it to do HTTPS things are just a little more complex - it's not a simple as passing it https as a scheme, instead you need to make a specific call to trigger the SSL handshake

This snippet shows how to do that (using a keepalive pool to reduce connection overhead between requests)

Read more…

Lowercase URL Encoding with Urllib in Python3 (Python3)

Python's urllib module is pretty flexible, and contains a bunch of useful tools - including the ability to urlencode strings via urllib.parse.quote()

Unfortunately, it doesn't allow you to specify what case should be used in URL encoding, and defaults to upper-case. Many other libraries/languages use lower case.

This becomes problematic where you're url encoding an authentication token (or similar) - when the other side mints a token for comparison, the two will not match in a like for like comparison (and if the other end urldecodes your input, they're doing more processing on untrusted input that should be necessary - similarly passing through lower will affect the entire token and massively increase the chance of collisions).

This little wrapper function allows you to do a lowercase url-encode

Read more…