Skip to content

Instantly share code, notes, and snippets.

@cramforce
cramforce / example.gs
Last active Jun 18, 2021
Running VBA in Google Spreadsheet Apps Script
View example.gs
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)
}
View dom-based-weakref.js
/**
* 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 / vc.md
Last active Apr 18, 2021
Malte's home video conferencing setup
View vc.md
  • 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
@cramforce
cramforce / ambient-illuminance-dimmer.groovy
Last active Apr 24, 2020
Adjusts accent light dimming to maintain a ~constant relative brightness compared to ambient luminance
View ambient-illuminance-dimmer.groovy
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 / elgato-key-light-smartthings-device-handler.groovy
Last active Feb 19, 2021
A SmartThings Device Handler for Elgato Key Light
View elgato-key-light-smartthings-device-handler.groovy
/**
* 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
@cramforce
cramforce / simple-thermostat.groovy
Created Nov 5, 2019
Simple SmartThings Thermostat
View simple-thermostat.groovy
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 / settimeout.groovy
Created Dec 25, 2018
Debounce switches in SmartThings via switches, contact, and motion sensors.
View settimeout.groovy
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"
)
@cramforce
cramforce / dig.txt
Created Sep 6, 2017
dig foo.cdn.ampproject.org
View dig.txt
dig foo.cdn.ampproject.org
@cramforce
cramforce / main.py
Created Jul 17, 2017
Google App Engine ADT Pulse alert email to IFTT webhook adapter
View main.py
import logging
import re
# Receives alert emails from ADT Pulse and expects them to have
# an extra text of the form 'action=YOUR_ACTION' in the body.
# Calls IFTT with your key and the given action to trigger a webhook.
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.api import urlfetch
import webapp2
@cramforce
cramforce / on-idle.js
Created Dec 7, 2016
Wrapper around requestIdleCallback to wait for a minimum work budget
View on-idle.js
/**
* Delays calling the given function until the browser is notifying us
* about a certain minimum budget or the timeout is reached.
* @param {!Window} win
* @param {number} startTime When we started waiting for idle.
* @param {number} minimumTimeRemaining Minimum number of millis idle
* budget for callback to fire.
* @param {number} timeout in millis for callback to fire.
* @param {function()} fn Callback.
*/