Skip to content

Instantly share code, notes, and snippets.

View alastaircoote's full-sized avatar

Alastair Coote alastaircoote

View GitHub Profile
@alastaircoote
alastaircoote / lutron_pico_5_button_actions.yaml
Last active October 23, 2023 16:51
Lutron Pico 5 Buttons (more device types)
blueprint:
name: Lutron Pico 5 Button Actions
description: |
Different Actions on Short, Long, and Double Click button presses.
There is no Double Click for up/down as those are slower to respond and produce bad experience.
Make sure you have enabled at least one Pico Event Entity for each device, they are default to not enabled as of 2023.3, otherwise they won't show up as an available device in the drop down list.
domain: automation
input:
const stream = new ReadableStream({
start: async function(controller) {
controller.enqueue("<html>");
let content = await getSomeContent();
controller.enqueue(content);
controller.enqueue("</html>");
}
});
let r = new Response(stream,{

Keybase proof

I hereby claim:

  • I am alastaircoote on github.
  • I am alastair (https://keybase.io/alastair) on keybase.
  • I have a public key whose fingerprint is 09CE E35D 405E DD3C 46B0 27D2 17C9 9C92 91E4 E05B

To claim this, I am signing this object:

import opentype from 'opentype.js';
let lastRenderTime = null;
let x = 0;
let y = 0;
let moveBackwards = false;
let moveUp = false;
let logoImg = null;
let parsedFont = null;
const trySubscribeAction = function(id, action, log) {
return Promise.resolve()
.then( () => {
if (action == "subscribe") {
return subscribePromise(id);
} else {
return unsubscribePromise(id);
}
})
.then( (result) => {
@alastaircoote
alastaircoote / view.sql
Last active September 15, 2016 16:58
View schema for grouped log entries
SELECT
min(log_entries."time") AS "time",
max(log_entries.level) AS level,
jsonb_merge(log_entries.data) AS data,
json_agg(log_entries.msg) AS msg,
log_entries.req_id
FROM log_entries
GROUP BY log_entries.req_id
CREATE OR REPLACE FUNCTION jsonb_merge_state(jsonb, jsonb)
returns jsonb
language sql
as $$
SELECT $1 || $2
$$;
DROP AGGREGATE IF EXISTS jsonb_merge(jsonb);
CREATE AGGREGATE jsonb_merge(jsonb) (
class DbStream extends stream.Writable {
constructor() {
super( {objectMode: true} );
}
_write(data, encoding, cb) {
let specificFields = ["name", "pid", "hostname", "time", "level", "msg", "req_id", "v"];
let fieldData = [];
@alastaircoote
alastaircoote / log_schema.sql
Last active September 15, 2016 16:11
Schema for Postgres logging table
CREATE TABLE "log_entries" (
"id" serial PRIMARY KEY,
"name" varchar NOT NULL,
"pid" int8 NOT NULL,
"hostname" varchar NOT NULL,
"time" timestamp NOT NULL,
"level" integer NOT NULL,
"msg" varchar NOT NULL,
"v" integer NOT NULL,
"req_id" varchar,
var webviewProvider = (function() {
if (/\/FBIOS/i.test(navigator.userAgent) === true) {
return 'facebook';
}
if (/Twitter for/i.test(navigator.userAgent) === true) {
return 'twitter';
}
if (/Pinterest\//.test(navigator.userAgent) === true) {
return 'pinterest';
}