Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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)
}
/**
* 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 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
@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 / 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
@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 / 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"
)
@cramforce
cramforce / dig.txt
Created September 6, 2017 16:06
dig foo.cdn.ampproject.org
dig foo.cdn.ampproject.org
@cramforce
cramforce / main.py
Created July 17, 2017 04:04
Google App Engine ADT Pulse alert email to IFTT webhook adapter
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