Skip to content

Instantly share code, notes, and snippets.

View cjheath's full-sized avatar

Clifford Heath cjheath

View GitHub Profile
@cjheath
cjheath / recording.idle
Created April 4, 2022 05:23
Daikin P1P2 recording
FF 00 10 00 61 FD 3D 06 11 00 02 FF FF AA 02 80 BF FF 57 D5 02 62 B6 01
88 FF FB EF 99 00 84 7F FF DF 95 00 FF FF 55 01 70 FF
FF 9B 54 54 00 00 2C FF AF A6 32 F7 5B AD D2 FB 1B 00 34 BF 4B 15 00 EF
7F 57 2B 20 FF 7B BF FF 55 3C
FF B7 3E 77 68 FF F3 BF 23 90 FF FF BF 6F AD 95 41 BF 3C 9F FD 57 4F CB
FF 00 10 5E 6D 8D 1D 00 11 FB 57 2A 02 00 00 FF BF 55 2A 02 00 BB DB 10
0C 10 D8 9B 05 11 7F FF 55 01 40 FF FF 5D 15 80 FF
@cjheath
cjheath / char_pointer.h
Created March 13, 2022 10:07
A C++ class that encapsulates a pointer to UTF-8 data so that "normal" char-pointer work in multi-byte UTF-8
// See https://github.com/cjheath/strpp/blob/main/include/char_encoding.h
#include <char_encoding.h>
// This MOSTLY works. I just need a way to make these both work:
// UCS4 ch = *ptr++;
// *ptr++ = ch; // <<<< This is the tricky one.
class UTF8P
{
private:
UTF8* data;
9 = 32
99 = 32 × 11
999 = 33 × 37
9999 = 32 × 11 × 101
99999 = 32 × 41 × 271
999999 = 33 × >>>> 7 <<<< × 11 × 13 × 37
9 999999 = 32 × 239 × 4649
99 999999 = 32 × 11 × 73 × 101 × 137
999 999999 = 34 × 37 × 333667
@cjheath
cjheath / long_repeaters.rb
Created April 5, 2021 12:39
Find integers n whose reciprocal has n-1 repeating digits
MAX_DIGITS = 1000
7.upto(MAX_DIGITS) do |i|
scaled_reciprocal = (10**(i*2)) / i
digits = sprintf("%0#{2*i}d", scaled_reciprocal)
# printf "%d -> 0.%s...\n", i, digits
first_repeat = nil
offset = nil
1.upto(i-1) do |r|
# Break the digits into as many groups of r characters as possible
#! /bin/bash
# Get electricity price data from Amber, and usage/generation/grid power from a Fronius inverter (site), and report.
#
# (c) Copyright 2020 Clifford Heath.
# Code is known to be incorrect. Free for use at your own risk.
# Per Amber interim API documentation:
# All timestamps in the data are market time (ie Brisbane time) and at period end,
# not start (so if it's 915am, the current period is the 930am one).
module AlbumArtist
extend ActiveSupport::Concern
included do
validates :album_id, :presence => true
validates :artist_id, :presence => true
end
end
module FollowedPlaylist
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public;
CREATE TABLE album_artist (
-- Album Artist involves Album that has Album ID
album_id ID NOT NULL,
-- Album Artist involves Artist that has Artist ID
artist_id ID NOT NULL,
-- Primary index to Album Artist(Album, Artist in "Album is by Artist")
PRIMARY KEY(album_id, artist_id)
@cjheath
cjheath / cql.rake
Created December 6, 2018 04:19
lib/tasks/cql.rake for a Rails Application
namespace 'cql' do
APPLICATION = 'my-app-name'
desc 'Check that there are no errors in CQL'
task :check do
system <<-END
set -x
cd "db/app"
schema_compositor --binary #{APPLICATION}.cql
END
Dear Mygov,
Your web-based single sign-on solution is riddled with obvious bugs,
and is clearly built by incompetent staff and paid for by people
who DO NOT CARE about that. I've been in the software industry for
35 years and I have never seen such an important service so
comprehensively fouled up.
The first and most obvious thing is just a niggle: whenever I
re-visit the www.mygov.gov.au home page, I'm greeted by "Sorry,
@cjheath
cjheath / gist:465f2113063c6a910dc1
Created May 9, 2014 22:55
cjheath's keybase proof
### Keybase proof
I hereby claim:
* I am cjheath on github.
* I am cjheath (https://keybase.io/cjheath) on keybase.
* I have a public key whose fingerprint is B3B5 4A9F ADA5 DE58 DBBF 9EE0 44EB 9A2F 5B66 0046
To claim this, I am signing this object: