Skip to content

Instantly share code, notes, and snippets.

@cramforce
cramforce / elgato-key-light-smartthings-device-handler.groovy
Last active February 23, 2023 06:20
A SmartThings Device Handler for Elgato Key Light
/**
* Copyright 2020 Malte Ubl
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
const SCRIPT_TAG = '<script async src="/feedback-bootstrap.js"></script>';
export async function middleware(request: NextRequest) {
// Skip requests not looking for html.
const accept = request.headers.get("accept") || "";
if (!accept) {
console.log("Request headers", request.headers);
@cramforce
cramforce / example.gs
Last active June 18, 2021 15:42
Running VBA in Google Spreadsheet Apps Script
function area(x, y) {
VBA`
Function Area(x As Double, y As Double) As Double
Area = Math.round(x * y)
End Function
`
return Area(x, y)
}
@cramforce
cramforce / vc.md
Last active April 18, 2021 17:42
Malte's home video conferencing setup
  • Lights: Elgato Key Lights (2, one as actual key light, one as fill light)
    • Looking into these lights can cause fatigue after a while, which sucks if you're doing that all day.
    • I managed to work around it by heavily dimming one light that is in my field of view and moving the other light out of my field of view.
  • Microphone: Blue Snowball Ice
  • Microphone pop filter
  • Wall/ceiling mounts for camera and lights
  • Camera: Sony a6000.
    • This is one of multiple older Sony mirrorless cameras recommended for streaming.
  • Whichever you buy, make sure the reviews mention that it can stay on
/**
* A `WeakRef` polyfill that works for DOM Elements only.
*
* NOTE, and this is a big NOTE, that the fallback implementation fails to
* `deref` an element if it is no longer in the respective document.
* Technically it could still be around, but for the purpose of this class
* we assume that the element is not longer reachable.
*/
export class DomBasedWeakRef {
/**
@cramforce
cramforce / ambient-illuminance-dimmer.groovy
Last active April 24, 2020 04:50
Adjusts accent light dimming to maintain a ~constant relative brightness compared to ambient luminance
definition(
name: "Ambient Illuminance Dimmer",
namespace: "cramforce",
author: "Malte",
description: "Adjusts accent light dimming to maintain a ~constant relative brightness compared to ambient luminance",
category: "Convenience",
iconUrl: "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Candle.jpg/1200px-Candle.jpg",
iconX2Url: "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Candle.jpg/1200px-Candle.jpg"
)
@cramforce
cramforce / simple-thermostat.groovy
Created November 5, 2019 03:48
Simple SmartThings Thermostat
definition(
name: "Outdoor Thermostat",
namespace: "cramforce",
author: "Malte",
description: "Simple SmartThings Thermostat",
category: "Convenience",
iconUrl: "https://s3.images-iherb.com/sns/sns01567/u/3.jpg",
iconX2Url: "https://s3.images-iherb.com/sns/sns01567/u/3.jpg"
)
@cramforce
cramforce / javascript_will_listen.txt
Created October 9, 2011 20:35 — forked from joemccann/javascript_will_listen.md
JavaScript Will Listen - By Bella Morningstar
Artist: https://twitter.com/mandylauderdale
I wouldn't be so alone
If my Github followers lived in my home
Alex Russell would send a pull request
But I'd be too busy
Return to San Francisco by nine
That guy Brendan Eich, did he see my sign
He makes me smile all the time
His lines of code would compliment mine
@cramforce
cramforce / settimeout.groovy
Created December 25, 2018 05:18
Debounce switches in SmartThings via switches, contact, and motion sensors.
definition(
name: "setTimeout",
namespace: "cramforce",
author: "Malte",
description: "Debounce switches based on switches, contact, and motion sensors.",
category: "Convenience",
iconUrl: "https://png.pngtree.com/svg/20170719/react_1353128.png",
iconX2Url: "https://png.pngtree.com/svg/20170719/react_1353128.png"
)
--angular_pass : Generate $inject properties for
AngularJS for functions annotated
with @ngInject
--charset VAL : Input and output charset for all
files. By default, we accept UTF-8 as
input and output US_ASCII
--checks-only : Don't generate output. Run checks,
but no compiler passes.
--closure_entry_point VAL : Entry points to the program. Must be
goog.provide'd symbols. Any goog.provi