Skip to content

Instantly share code, notes, and snippets.

View mattpocock's full-sized avatar

Matt Pocock mattpocock

View GitHub Profile
// Name: Trim latest OBS video
import "@johnlindquist/kit";
const { stdout } = await $`ls -t ~/Movies/*.mp4 | head -n 1`;
const inputVideo = stdout.trim();
const outputVideo = home("Movies", "trimmed", path.parse(inputVideo).base);
// Name: Trim latest OBS video
import "@johnlindquist/kit";
import { z } from "zod";
import { getActiveEditorFilePath } from "./helpers/vscode";
const { stdout } = await $`ls -t ~/Movies/*.mp4 | head -n 1`;
const inputVideo = stdout.trim();
// Name: Trim latest OBS video
import "@johnlindquist/kit";
import { z } from "zod";
const { stdout } = await $`ls -t ~/Movies/*.mp4 | head -n 1`;
const inputVideo = stdout.trim();
const THRESH = "-40";
// Name: convert to webp
import "@johnlindquist/kit";
import * as path from "path";
const folder = await selectFolder("Select folder to convert from png to webp");
const files = await readdir(folder);
const pngFiles = files
// Name: Stop Work
// Description: It's the end of the day! Time to chill.
import "@johnlindquist/kit";
const appsToClose = [
`Slack`,
`Discord`,
`QuickTime Player`,
`Centered`,
// Name: Delete node modules
import "@johnlindquist/kit";
await $`find ~/repos -name 'node_modules' -type d -prune -exec rm -rf '{}' +`;
// Name: convert to webp
import "@johnlindquist/kit";
import * as path from "path";
const folder = await selectFolder("Select folder to convert from png to webp");
const files = await readdir(folder);
const pngFiles = files

Build the logic for a network quality indicator:

Requirements:

  1. Every time the REPORT_NETWORK_QUALITY event comes in, I want to assign its results to context (no matter what else happens)
  2. If the network quality is bad or worse, we want to show a warning
  3. If the network quality gets better, we want to hide the warning again
  4. The warning must show for a minimum of 2 seconds, we don't want any weird flickering.
  5. The user should be able to dismiss the warning forever using the DISMISS_NETWORK_QUALITY_WARNING. The warning should never show again.
@mattpocock
mattpocock / machine.js
Created August 3, 2021 18:35
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import { Machine, assign } from 'xstate';
import { FetchOptions } from './fetchMachine.machine.typed';
export type MessageStatus = { status: string };
export type FetchEvent =
| {
type: 'done.invoke.fetchData';
data: Response;
}