Skip to content

Instantly share code, notes, and snippets.

@kurrik
kurrik / ffmpeg.md
Last active December 5, 2023 02:16
FFmpeg

FFmpeg invocations

# Stuff downloaded by yt-dlp comes out as webm, which is less supported in editors
ffmpeg -i input.webm -strict experimental output.mp4

# Alternatively just download & convert in a single step
yt-dlp VIDEO_ID --recode-video mp4 -o VIDEO_TITLE.mp4
@kurrik
kurrik / README.md
Last active June 24, 2023 19:16
Call Google services from a service account using account delegation on Cloudflare Workers

Call Google services from a service account using account delegation on Cloudflare Workers

I had to figure this out for the nyt-connections project but wound up not using it because even with this auth scheme you can't list messages from chat rooms which allow non-domain users to be added.

Credentials

Create a service account in https://console.cloud.google.com/iam-admin/serviceaccounts?supportedpurview=project

Delegating domain-wide authority to the service account (needs a pro workspace):

@kurrik
kurrik / clipboard.md
Created July 7, 2022 20:46
Read clipboard data in browser

Read clipboard data in the browser.

You can paste this into devtools. Note that the clipboard API requires the document to be focused, so we wrap in a timeout. You need to switch focus to the active document before the timeout fires.

window.setTimeout(async () => {
   const contents = await navigator.clipboard.read();
   for (var i = 0; i < contents.length; i++) {
       const item = contents[i];
       const types = item.types;
await types.forEach(async (t) =&gt; {
@kurrik
kurrik / README.md
Last active November 19, 2021 01:11
Paid trial subscriptions on Stripe

Paid trial subscriptions on Stripe

This is an example of how to set up a Stripe Billing subscription with a short paid trialing period which automatically transitions into a regular price unless it is canceled. This was requested in https://twitter.com/abinaya_rl/status/1458275686930546693

Ability to start a trial period with $1 for 7 days and then after the trial charge the users 10$/monthly.

This behavior is currently possible using subscription schedules and an introductory price with a 1 week duration.

Requirements

You need the Stripe CLI tool and jq installed.

@kurrik
kurrik / Code.gs
Created November 10, 2021 19:50
Google Form -> Email sending script
function onFormSubmit(e) {
const itemResponses = e.response.getItemResponses();
const formData = itemResponses.map((ir) => {
const i = ir.getItem();
return {
'question': i.getTitle(),
'response': getResponse(ir),
};
});
const emailData = {
@kurrik
kurrik / elgato-key-light-smartthings-device-handler.groovy
Last active September 27, 2021 18:54 — forked from cramforce/elgato-key-light-smartthings-device-handler.groovy
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
@kurrik
kurrik / GoogleForms-CustomDestination.gs
Last active August 24, 2021 00:56
Sending nicely-formatted change emails from Google Apps Forms
/**
* This script sends an email in response to form submissions.
* It formats metadata specified in the form and may be configured
* to send to different audiences depending on which options are
* chosen. The email is nicely formatted, suitable for ingestion
* into Slack.
**/
/** CHANGE THE FOLLOWING TO MATCH YOUR FORM **/
@kurrik
kurrik / stripe-cli.sh
Created August 12, 2021 17:03
Stripe CLI tricks
# Print the currently configured account's test mode API key (in case you need to pass to a script / curl):
stripe config --list | awk '$1=="test_mode_api_key"{gsub(/"/, "", $3);print $3}'
@kurrik
kurrik / AppsScriptEmailFormResponsesWithImages.gs
Last active January 23, 2021 20:17
AppsScript for emailing form responses with images
function onFormSubmit(e) {
const itemResponses = e.response.getItemResponses();
const formData = itemResponses.map((ir) => {
const i = ir.getItem();
return {
'question': i.getTitle(),
'response': getResponse(ir),
};
});
const emailData = {
@kurrik
kurrik / manifest.json
Created March 31, 2014 17:13
Including embedded Tweets in a Google Chrome extension
{
"manifest_version": 2,
"name": "crx-widgetsjs",
"description": "Load Twitter's widgets.js in a Chrome extension",
"version": "1.0",
"permissions": [
],
"browser_action": {