Skip to content

Instantly share code, notes, and snippets.

View jpettitt's full-sized avatar

John Pettitt jpettitt

View GitHub Profile
@jpettitt
jpettitt / HAEnrgy.yaml
Last active April 25, 2023 14:26
Home Assistant Energy Dashboard
views:
- title: Live Energy Data
path: test
type: custom:grid-layout
layout:
grid-template-columns: 50% 50%
card_margin: 0 0 0 0
margin: 0
grid-template-rows: auto
grid-template-areas: |
@jpettitt
jpettitt / HomeAssistant Color Temp Grid
Created November 12, 2022 22:13
A recipe for home assistant entity temperature numeric values that are color coded by value
# Uses Apex-Charts (install from HACS)
# Define an Apex Charts template in the main view YAML
# Saves repeating it for every sensor
apexcharts_card_templates:
color_temp:
# Install card mod and adjust font size accounding to taste or just remove
card_mod:
style: |
ha-card {
font-size: 16px
@jpettitt
jpettitt / ha_nut_runtime_templat_hhmmss.yaml
Last active September 18, 2022 20:55
Home Assistant Template for UPS Battery Runtime in hh:mm:ss
# UPS runtime in hh:mm:ss
# converts run time to seconds since unix epoc 1970-01-10T00:00Z
# to do this it uses this to get the locale time offset
# 0 | timestamp_custom('%s') | float
- platform: template
sensors:
server_rack_ups_runtime_mins:
friendly_name: "Server Rack UPS Runtime"
value_template: >-
{{ (states.sensor.server_rack_battery_runtime.state | float - (0 | timestamp_custom('%s') | float)) | timestamp_custom('%X') }}
@jpettitt
jpettitt / home_assistant_tmobile_home_internet.yaml
Last active August 11, 2023 06:06
Home Assistant config for T-Mobile Home Internet Arcadyan Router
# T-Mobile Internet
#
# TMobile Home Internet Sensors
# Arcadyan Router
#
- platform: rest
# All of these seem to use the same IP
resource: http://192.168.12.1/TMI/v1/gateway?get=all
scan_interval: 60
@jpettitt
jpettitt / fictional-publications.md
Last active February 8, 2022 18:35
Fictional News Publications

Fictional Newspapers as Examples in Documents

by @jpettitt, updated: 2021-05-20

The Daily Planet. Superman

The Metropolis Star. Superman

The Sheepdog Times. Seb

The Gotham Gazette. Batman

@jpettitt
jpettitt / keybase.md
Created October 22, 2021 23:13
Keybase claim

Keybase proof

I hereby claim:

  • I am jpettitt on github.
  • I am johnpettitt (https://keybase.io/johnpettitt) on keybase.
  • I have a public key ASBxYcTl2eb-XF8SB57qK6k0AVPN0HLFQKhtnU7b1Bjwego

To claim this, I am signing this object:

@jpettitt
jpettitt / amp-bind-toggle.html
Last active February 23, 2018 19:34
A simple toggle using amp-bind
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>amp-bind</title>
<link rel="canonical" href="https://ampbyexample.com/components/amp-bind/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
@jpettitt
jpettitt / index.js
Last active May 9, 2019 01:58
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var url = require('url');
var qs = require('qs');
var assert = require('assert')
var parsed = url.parse('http://www.example.com/somepath?x=1');
var parsedQuery = qs.parse(parsed.query);
assert.deepEqual(parsedQuery, { x: 1 });
@jpettitt
jpettitt / HTMLClassCounter.js
Last active July 29, 2016 18:54
Count the number of distinct classes, ids and node types in use on a web page
/*
* Copy and paste into browser console to find out how many classes, ids and nodes a page actually uses
*/
function countClass() {
const elements = document.querySelectorAll('*');
const ids = {};
const classes= {};
const nodes = {}