Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View andysc's full-sized avatar

Andy Stanford-Clark andysc

View GitHub Profile
@andysc
andysc / perl_wrap.pl
Created October 31, 2012 19:12
wrap input to 32 columns, breaking on spaces
while (<>)
{
chomp;
$line = $_;
while (length($line) > 32)
{
$bit = substr($line,0,32);
$space = rindex($bit," ");
if ($space == -1)
@andysc
andysc / cpu.pl
Last active April 6, 2022 03:03
Blink(1) CPU monitor for linux. A little perl app which uses vmstat to see how busy the CPU is, and turn the Blink(1) blue through magenta through red, accordingly, using the command-line blink1-tool
# cpu.pl
# Andy Stanford-Clark
# Feb-13
# seconds between readings from vmstat
$sample_interval = 30;
# drive a blink(1) to represent the CPU usage
# blue is low, red is high
@andysc
andysc / IPspeak.pl
Last active June 6, 2020 18:11
Speak the IP address of your linux machine. Perfect for Raspberry PIs or other headless servers with audio output. Just plug in a speaker or earphones and wait to be told the IP address to ssh to!
#!/usr/bin/perl
# IPspeak
# Andy S-C
# 18-May-13
# 15-Oct-16 - made more "human" ... ten dot nought dot one nine three dot seventeen
# this is the order we check the interfaces
@interfaces = ("eth0", "wlan0");

Keybase proof

I hereby claim:

  • I am andysc on github.
  • I am andysc (https://keybase.io/andysc) on keybase.
  • I have a public key whose fingerprint is 46B1 D988 19C2 17E5 3E0F B550 49D0 0F04 5205 80DD

To claim this, I am signing this object:

@andysc
andysc / README.md
Last active March 15, 2019 21:28
Tide model calculator for @DrLucyRogers' SeeTide IoT device

This is the back-end for a device that displays how high the tide is at a specific location in real-time.

It is the code referred to in this blog post by @DrLucyRogers: SeeTide.

The blog post explains how you find your coastal location and plug it into the HTTP input node.

Tidal data is scraped from the UK Hydrographic Easy Tide web site once a day, and the flow creates a number of sine-wave models of the day's tide, peaking and troughing at the correct high and low tide times.

The model is then run every 5 minutes to compute how far in or out the tide currently is, and formats a string of RGB colours to send over MQTT to a neopixel display device that displays the green/blue mix to show land and sea.

### Keybase proof
I hereby claim:
* I am andysc on github.
* I am andysc (https://keybase.io/andysc) on keybase.
* I have a public key whose fingerprint is 5BF6 980E 6884 C2F2 F69C 55B4 2D47 D52C 2E36 3F9D
To claim this, I am signing this object:
@andysc
andysc / README.md
Created June 25, 2014 12:29
remote control of Humax HDR-FOX T2 DVR using Node-RED

The Humax HDR-FOX T2 digital video recorder has a popular firmware hack which enables a web server with a UI for remote management of the Humax.

(see http://hummy.tv/forum/threads/quick-start-guide.1301/ - use at your own risk, invalidates warranty, etc).

Anyway, if you've done that, one of the "apps" is a web version of the remote control. This sends HTTP requests to the Humax web interface to inject commands as if they're button presses on the remote.

There is a debug window on the web interface which tells you the names of the commands it sends, so you can extend this flow to add additional buttons and sequences very easily. I've just shown a few basic ones (and the STANDBY command, which took slightly more effort to discover!).

Replace the IP address in the HTTPrequest node with the IP address of your Humax (there's a menu option in the Humax settings which tells you, or look in your router's DHCP table).