notes by alifeee profile picture rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (44), scripting (13), linux (5), bash (4), geojson (4), obsidian (4), android (3), github (3), html (3), jq (3) ............ see all (+54)

viewing a single note

comparing EPC certificates with git-diff # source

tags: git-diff, scripting, housing • 484 'words', 145 secs @ 200wpm

Our house just got a new EPC certificate. You can (maybe) check yours on https://www.gov.uk/find-energy-certificate.

I'm interested in easy ways to see change. Trying to compare the old and new webpages by eye is hard, which leads me to text-diffing. I can copy the contents of the website to a file and compare them that way. Let's. I did a similar thing a while ago with computer benchmarks.

I manually create two files by copying the interesting bits of the webpage, called 1 and 2 (because who has time for .txt extensions). Then, I can run:

git diff --no-index -U1000 ~/1 ~/2 > diff.txt
cat diff.txt | sed -E 's#^\+(.*)#<ins>\1</ins>#' | sed -E 's#^-(.*)#<del>\1</del>#' | sed 's/^ //'

The latter command turns each into HTML by turning + lines into <ins> ("insert"), - into <del> ("delete"), and removing leading spaces on other lines. Then, I can whack the output into a simple HTML template:

<!DOCTYPE html>
<html>
  <head>
    <style>
    body { background: black; color: white; }
    pre { padding: 1rem; }
    del { text-decoration: none; color: red; }
    ins { text-decoration: none; color: green; }
    </style>
  </head>
  <body>
<pre>
diff goes here...
<del>del lines will be red</del>
<ins>ins lines will be green</ins>
</pre>
  </body>
</html>

The final output is something like this (personal information removed. don't doxx me.)

Energy rating
D

Valid until 05 February 2025 05 February 2035

Property type Mid-terrace house Total floor area 130 square metres 123 square metres

This property’s energy rating is D. It has the potential to be C. This property’s energy rating is D. It has the potential to be B.

Features in this property

Window Fully double glazed Good Roof Pitched, no insulation (assumed) Very poor Roof Roof room(s), no insulation (assumed) Very poor Roof Roof room(s), insulated (assumed) Good Lighting Low energy lighting in 64% of fixed outlets Good Lighting Low energy lighting in all fixed outlets Very good Secondary heating None N/A

Primary energy use

The primary energy use for this property per year is 303 kilowatt hours per square metre (kWh/m2). The primary energy use for this property per year is 252 kilowatt hours per square metre (kWh/m2).

Good job on us for having 100% low energy lighting fixtures, I guess...

Really, this is a complicated way to simplify something. I like simple things, so I like this.

back to top back to main page